int msm_dss_enable_vreg(struct dss_vreg *in_vreg, int num_vreg, int enable) { int i = 0, rc = 0; if (enable) { for (i = 0; i < num_vreg; i++) { rc = PTR_RET(in_vreg[i].vreg); if (rc) { DEV_ERR("%pS->%s: %s regulator error. rc=%d\n", __builtin_return_address(0), __func__, in_vreg[i].vreg_name, rc); goto disable_vreg; } rc = regulator_enable(in_vreg[i].vreg); if (rc < 0) { DEV_ERR("%pS->%s: %s enable failed\n", __builtin_return_address(0), __func__, in_vreg[i].vreg_name); goto disable_vreg; } } } else { for (i = num_vreg-1; i >= 0; i--) if (regulator_is_enabled(in_vreg[i].vreg)) regulator_disable(in_vreg[i].vreg); } return rc; disable_vreg: for (i--; i >= 0; i--) regulator_disable(in_vreg[i].vreg); return rc; } /* msm_dss_enable_vreg */
static int hdmi_tx_clk_set_rate(struct hdmi_tx_platform_data *pdata, u32 clk_idx, unsigned long clk_rate) { int rc = 0; struct clk *clk = NULL; if (!pdata) { DEV_ERR("%s: invalid input\n", __func__); return -EINVAL; } clk = hdmi_tx_get_clk(pdata, clk_idx); if (clk) { rc = clk_set_rate(clk, clk_rate); if (IS_ERR_VALUE(rc)) DEV_ERR("%s: failed rc=%d\n", __func__, rc); else DEV_DBG("%s: clk=%d rate=%lu\n", __func__, clk_idx, clk_rate); } else { DEV_ERR("%s: FAILED: invalid clk_idx=%d\n", __func__, clk_idx); rc = -EINVAL; } return rc; } /* hdmi_tx_clk_set_rate */
/* create external interface kobject and initialize */ int external_common_state_create(struct platform_device *pdev) { int rc; struct msm_fb_data_type *mfd = platform_get_drvdata(pdev); if (!mfd) { DEV_ERR("%s: mfd not found\n", __func__); return -ENODEV; } if (!mfd->fbi) { DEV_ERR("%s: mfd->fbi not found\n", __func__); return -ENODEV; } if (!mfd->fbi->dev) { DEV_ERR("%s: mfd->fbi->dev not found\n", __func__); return -ENODEV; } rc = sysfs_create_group(&mfd->fbi->dev->kobj, &external_common_fs_attr_group); if (rc) { DEV_ERR("%s: sysfs group creation failed, rc=%d\n", __func__, rc); return rc; } external_common_state->uevent_kobj = &mfd->fbi->dev->kobj; DEV_ERR("%s: sysfs group %p\n", __func__, external_common_state->uevent_kobj); kobject_uevent(external_common_state->uevent_kobj, KOBJ_ADD); DEV_DBG("%s: kobject_uevent(KOBJ_ADD)\n", __func__); return 0; }
static int hdmi_tx_register_panel(struct hdmi_tx_ctrl *hdmi_ctrl) { int rc = 0; if (!hdmi_ctrl) { DEV_ERR("%s: invalid input\n", __func__); return -EINVAL; } hdmi_ctrl->panel_data.on = hdmi_tx_power_on; hdmi_ctrl->panel_data.off = hdmi_tx_power_off; hdmi_ctrl->video_resolution = HDMI_VFRMT_1920x1080p60_16_9; rc = hdmi_tx_init_panel_info(hdmi_ctrl->video_resolution, &hdmi_ctrl->panel_data.panel_info); if (rc) { DEV_ERR("%s: hdmi_init_panel_info failed\n", __func__); return rc; } rc = mdss_register_panel(&hdmi_ctrl->panel_data); if (rc) { DEV_ERR("%s: FAILED: to register HDMI panel\n", __func__); return rc; } return rc; } /* hdmi_tx_register_panel */
int msm_dss_clk_set_rate(struct dss_clk *clk_arry, int num_clk) { int i, rc = 0; for (i = 0; i < num_clk; i++) { if (clk_arry[i].clk) { if (DSS_CLK_AHB != clk_arry[i].type) { DEV_DBG("%pS->%s: '%s' rate %ld\n", __builtin_return_address(0), __func__, clk_arry[i].clk_name, clk_arry[i].rate); rc = clk_set_rate(clk_arry[i].clk, clk_arry[i].rate); if (rc) { DEV_ERR("%pS->%s: %s failed. rc=%d\n", __builtin_return_address(0), __func__, clk_arry[i].clk_name, rc); break; } } } else { DEV_ERR("%pS->%s: '%s' is not available\n", __builtin_return_address(0), __func__, clk_arry[i].clk_name); rc = -EPERM; break; } } return rc; } /* msm_dss_clk_set_rate */
int msm_dss_ioremap_byname(struct platform_device *pdev, struct dss_io_data *io_data, const char *name) { struct resource *res = NULL; if (!pdev || !io_data) { DEV_ERR("%pS->%s: invalid input\n", __builtin_return_address(0), __func__); return -EINVAL; } res = msm_dss_get_res_byname(pdev, IORESOURCE_MEM, name); if (!res) { DEV_ERR("%pS->%s: '%s' msm_dss_get_res_byname failed\n", __builtin_return_address(0), __func__, name); return -ENODEV; } io_data->len = resource_size(res); io_data->base = ioremap(res->start, io_data->len); if (!io_data->base) { DEV_ERR("%pS->%s: '%s' ioremap failed\n", __builtin_return_address(0), __func__, name); return -EIO; } return 0; } /* msm_dss_ioremap_byname */
static int hdmi_tx_check_capability(void __iomem *base) { u32 hdmi_disabled, hdcp_disabled; if (!base) { DEV_ERR("%s: invalid input\n", __func__); return -EINVAL; } /* QFPROM_RAW_FEAT_CONFIG_ROW0_LSB */ hdcp_disabled = HDMI_REG_R_ND(base, 0x000000F8) & BIT(31); /* QFPROM_RAW_FEAT_CONFIG_ROW0_MSB */ hdmi_disabled = HDMI_REG_R_ND(base, 0x000000FC) & BIT(0); DEV_DBG("%s: Features <HDMI:%s, HDCP:%s>\n", __func__, hdmi_disabled ? "OFF" : "ON", hdcp_disabled ? "OFF" : "ON"); if (hdmi_disabled) { DEV_ERR("%s: HDMI disabled\n", __func__); return -ENODEV; } if (hdcp_disabled) DEV_WARN("%s: HDCP disabled\n", __func__); return 0; } /* hdmi_tx_check_capability */
static int hdmi_tx_dev_init(struct hdmi_tx_ctrl *hdmi_ctrl) { int rc = 0; struct hdmi_tx_platform_data *pdata = NULL; if (!hdmi_ctrl) { DEV_ERR("%s: invalid input\n", __func__); return -EINVAL; } pdata = &hdmi_ctrl->pdata; rc = hdmi_tx_check_capability(pdata->io[HDMI_TX_QFPROM_IO].base); if (rc) { DEV_ERR("%s: no HDMI device\n", __func__); goto fail_no_hdmi; } /* irq enable/disable will be handled in hpd on/off */ hdmi_tx_hw.ptr = (void *)hdmi_ctrl; hdmi_tx_setup_video_mode_lut(); mutex_init(&hdmi_ctrl->mutex); hdmi_ctrl->workq = create_workqueue("hdmi_tx_workq"); if (!hdmi_ctrl->workq) { DEV_ERR("%s: hdmi_tx_workq creation failed.\n", __func__); goto fail_create_workq; } INIT_WORK(&hdmi_ctrl->hpd_state_work, hdmi_tx_hpd_state_work); init_timer(&hdmi_ctrl->hpd_state_timer); hdmi_ctrl->hpd_state_timer.function = hdmi_tx_hpd_state_timer; hdmi_ctrl->hpd_state_timer.data = (u32)hdmi_ctrl; hdmi_ctrl->hpd_state_timer.expires = 0xffffffffL; hdmi_ctrl->sdev.name = "hdmi"; if (switch_dev_register(&hdmi_ctrl->sdev) < 0) { DEV_ERR("%s: Hdmi switch registration failed\n", __func__); goto fail_switch_dev; } return 0; fail_switch_dev: del_timer(&hdmi_ctrl->hpd_state_timer); fail_create_workq: if (hdmi_ctrl->workq) destroy_workqueue(hdmi_ctrl->workq); mutex_destroy(&hdmi_ctrl->mutex); fail_no_hdmi: return rc; } /* hdmi_tx_dev_init */
int msm_dss_enable_gpio(struct dss_gpio *in_gpio, int num_gpio, int enable) { int i = 0, rc = 0; if (enable) { for (i = 0; i < num_gpio; i++) { DEV_DBG("%pS->%s: %s enable\n", __builtin_return_address(0), __func__, in_gpio[i].gpio_name); rc = gpio_request(in_gpio[i].gpio, in_gpio[i].gpio_name); if (rc < 0) { DEV_ERR("%pS->%s: %s enable failed\n", __builtin_return_address(0), __func__, in_gpio[i].gpio_name); goto disable_gpio; } gpio_set_value(in_gpio[i].gpio, in_gpio[i].value); } } else { for (i = num_gpio-1; i >= 0; i--) { DEV_DBG("%pS->%s: %s disable\n", __builtin_return_address(0), __func__, in_gpio[i].gpio_name); gpio_free(in_gpio[i].gpio); } } return rc; disable_gpio: for (i--; i >= 0; i--) gpio_free(in_gpio[i].gpio); return rc; } /* msm_dss_enable_gpio */
static void nfcsim_wq_recv(struct work_struct *work) { struct nfcsim *dev = container_of(work, struct nfcsim, recv_work.work); mutex_lock(&dev->lock); if (dev->shutting_down || !dev->up || !dev->clone_skb) { dev_kfree_skb(dev->clone_skb); goto exit; } if (dev->initiator) { if (!dev->cb) { DEV_ERR(dev, "Null recv callback\n"); dev_kfree_skb(dev->clone_skb); goto exit; } dev->cb(dev->cb_context, dev->clone_skb, 0); dev->cb = NULL; } else { nfc_tm_data_received(dev->nfc_dev, dev->clone_skb); } exit: dev->clone_skb = NULL; mutex_unlock(&dev->lock); }
int sp_write_reg(uint8_t slave_addr, uint8_t offset, uint8_t value) { int ret = 0; //printk("=======sp_write_reg ====%x====%x\n",slave_addr,offset); if ( (g_i2c_error_count > 20) || (g_tx_recovery_process)) return -1; anx7808_client->addr = (slave_addr >> 1); ret = i2c_smbus_write_byte_data(anx7808_client, offset, value); if (ret < 0) { DEV_ERR("%s: failed to write i2c addr=%x\n", __func__, slave_addr); if ((++g_i2c_error_count) > 20) { printk("myDP write i2c error, power down\n"); sp_tx_hardware_recovery(anx7808_client); } } else { g_i2c_error_count = 0; g_tx_recovery_process = 0; } return ret; }
int dsi_ctrl_config_init(struct platform_device *pdev, struct mdss_dsi_ctrl_pdata *ctrl_pdata) { int rc = 0, i; for (i = 0; i < DSI_MAX_PM; i++) { rc = mdss_dsi_get_dt_vreg_data(&pdev->dev, &ctrl_pdata->power_data[i], i); if (rc) { DEV_ERR("%s: '%s' get_dt_vreg_data failed.rc=%d\n", __func__, __mdss_dsi_pm_name(i), rc); return rc; } } rc = dsi_parse_gpio(pdev, ctrl_pdata); if (rc) { pr_err("fail to parse panel GPIOs\n"); return rc; } rc = dsi_parse_phy(pdev, ctrl_pdata); if (rc) { pr_err("fail to parse DSI PHY settings\n"); return rc; } return 0; }
static int __init tvout_init(void) { int ret; tvout_msm_state = kzalloc(sizeof(*tvout_msm_state), GFP_KERNEL); if (!tvout_msm_state) { DEV_ERR("tvout_msm_init FAILED: out of memory\n"); ret = -ENOMEM; goto init_exit; } external_common_state = &tvout_msm_state->common; ret = platform_driver_register(&this_driver); if (ret) { DEV_ERR("tvout_device_init FAILED: platform_driver_register\ rc=%d\n", ret); goto init_exit; } ret = platform_device_register(&this_device); if (ret) { DEV_ERR("tvout_device_init FAILED: platform_driver_register\ rc=%d\n", ret); platform_driver_unregister(&this_driver); goto init_exit; } INIT_WORK(&tvout_msm_state->hpd_work, tvout_msm_hpd_work); return 0; init_exit: kfree(tvout_msm_state); tvout_msm_state = NULL; return ret; }
static int hdmi_tx_init_panel_info(uint32_t resolution, struct mdss_panel_info *pinfo) { const struct hdmi_disp_mode_timing_type *timing = hdmi_get_supported_mode(resolution); if (!timing || !pinfo) { DEV_ERR("%s: invalid input.\n", __func__); return -EINVAL; } pinfo->xres = timing->active_h; pinfo->yres = timing->active_v; pinfo->clk_rate = timing->pixel_freq*1000; pinfo->lcdc.h_back_porch = timing->back_porch_h; pinfo->lcdc.h_front_porch = timing->front_porch_h; pinfo->lcdc.h_pulse_width = timing->pulse_width_h; pinfo->lcdc.v_back_porch = timing->back_porch_v; pinfo->lcdc.v_front_porch = timing->front_porch_v; pinfo->lcdc.v_pulse_width = timing->pulse_width_v; pinfo->type = DTV_PANEL; pinfo->pdest = DISPLAY_2; pinfo->wait_cycle = 0; pinfo->bpp = 24; pinfo->fb_num = 1; pinfo->lcdc.border_clr = 0; /* blk */ pinfo->lcdc.underflow_clr = 0xff; /* blue */ pinfo->lcdc.hsync_skew = 0; return 0; } /* hdmi_tx_init_panel_info */
int msm_dss_enable_clk(struct dss_clk *clk_arry, int num_clk, int enable) { int i, rc = 0; if (enable) { for (i = 0; i < num_clk; i++) { DEV_DBG("%pS->%s: enable '%s'\n", __builtin_return_address(0), __func__, clk_arry[i].clk_name); if (clk_arry[i].clk) { rc = clk_prepare_enable(clk_arry[i].clk); if (rc) DEV_ERR("%pS->%s: %s en fail. rc=%d\n", __builtin_return_address(0), __func__, clk_arry[i].clk_name, rc); } else { DEV_ERR("%pS->%s: '%s' is not available\n", __builtin_return_address(0), __func__, clk_arry[i].clk_name); rc = -EPERM; } if (rc) { msm_dss_enable_clk(&clk_arry[i], i, false); break; } } } else { for (i = num_clk - 1; i >= 0; i--) { DEV_DBG("%pS->%s: disable '%s'\n", __builtin_return_address(0), __func__, clk_arry[i].clk_name); if (clk_arry[i].clk) clk_disable_unprepare(clk_arry[i].clk); else DEV_ERR("%pS->%s: '%s' is not available\n", __builtin_return_address(0), __func__, clk_arry[i].clk_name); } } return rc; } /* msm_dss_enable_clk */
/* todo: revisit when new HPD debouncing logic is available */ static void hdmi_tx_hpd_state_timer(unsigned long data) { struct hdmi_tx_ctrl *hdmi_ctrl = (struct hdmi_tx_ctrl *)data; if (hdmi_ctrl) queue_work(hdmi_ctrl->workq, &hdmi_ctrl->hpd_state_work); else DEV_ERR("%s: invalid input\n", __func__); } /* hdmi_tx_hpd_state_timer */
static void slimport_edid_proc(void) { sp_tx_edid_read(); if (bedid_break) DEV_ERR("%s: EDID corruption!\n", __func__); hdmi_rx_set_hpd(1); hdmi_rx_set_termination(1); sp_tx_set_sys_state(STATE_CONFIG_HDMI); }
static inline struct clk *hdmi_tx_get_clk(struct hdmi_tx_platform_data *pdata, u32 clk_idx) { if (!pdata || clk_idx > HDMI_TX_MAX_CLK) { DEV_ERR("%s: invalid input\n", __func__); return NULL; } return pdata->clk[clk_idx]; } /* hdmi_tx_get_clk */
static void pci_dev_init_manager(struct device_mem *bar_info, int nr_mapped_bars) { errval_t err; DEV_DEBUG("Initialize device @ [%016lx] with %u bars\n", bar_info->paddr, nr_mapped_bars); if (nr_mapped_bars != 1) { DEV_ERR("number of mapped bars is wrong. Skipping initialization\n"); return; } err = ioat_mgr_svc_add_device(bar_info->frame_cap); if (err_is_fail(err)) { DEV_ERR("Device coult not be added to the manager: %s\n", err_getstring(err)); } }
static int nfcsim_dep_link_up(struct nfc_dev *nfc_dev, struct nfc_target *target, u8 comm_mode, u8 *gb, size_t gb_len) { int rc; struct nfcsim *dev = nfc_get_drvdata(nfc_dev); struct nfcsim *peer = dev->peer_dev; u8 *remote_gb; size_t remote_gb_len; DEV_DBG(dev, "target_idx: %d, comm_mode: %d\n", target->idx, comm_mode); mutex_lock(&peer->lock); nfc_tm_activated(peer->nfc_dev, NFC_PROTO_NFC_DEP_MASK, NFC_COMM_ACTIVE, gb, gb_len); remote_gb = nfc_get_local_general_bytes(peer->nfc_dev, &remote_gb_len); if (!remote_gb) { DEV_ERR(peer, "Can't get remote general bytes\n"); mutex_unlock(&peer->lock); return -EINVAL; } mutex_unlock(&peer->lock); mutex_lock(&dev->lock); rc = nfc_set_remote_general_bytes(nfc_dev, remote_gb, remote_gb_len); if (rc) { DEV_ERR(dev, "Can't set remote general bytes\n"); mutex_unlock(&dev->lock); return rc; } rc = nfc_dep_link_is_up(nfc_dev, target->idx, NFC_COMM_ACTIVE, NFC_RF_INITIATOR); mutex_unlock(&dev->lock); return rc; }
static struct resource *msm_dss_get_res_byname(struct platform_device *pdev, unsigned int type, const char *name) { struct resource *res = NULL; res = platform_get_resource_byname(pdev, type, name); if (!res) DEV_ERR("%s: '%s' resource not found\n", __func__, name); return res; } /* msm_dss_get_res_byname */
u32 dss_reg_r(struct dss_io_data *io, u32 offset, u32 debug) { u32 value; if (!io || !io->base) { DEV_ERR("%pS->%s: invalid input\n", __builtin_return_address(0), __func__); return -EINVAL; } if (offset > io->len) { DEV_ERR("%pS->%s: offset out of range\n", __builtin_return_address(0), __func__); return -EINVAL; } value = readl_relaxed(io->base + offset); if (debug) DEV_DBG("[%08x] <= %08x\n", (u32)(io->base + offset), value); return value; } /* dss_reg_r */
/* create HDMI kobject and initialize */ int hdmi_common_state_create(struct platform_device *pdev) { int rc; struct msm_fb_data_type *mfd = platform_get_drvdata(pdev); rc = sysfs_create_group(&mfd->fbi->dev->kobj, &hdmi_common_fs_attr_group); if (rc) { DEV_ERR("%s: sysfs group creation failed, rc=%d\n", __func__, rc); return rc; } hdmi_common_state->uevent_kobj = &mfd->fbi->dev->kobj; DEV_ERR("%s: sysfs group %p\n", __func__, hdmi_common_state->uevent_kobj); kobject_uevent(hdmi_common_state->uevent_kobj, KOBJ_ADD); DEV_DBG("%s: kobject_uevent(KOBJ_ADD)\n", __func__); return 0; }
static int nfcsim_start_poll(struct nfc_dev *nfc_dev, u32 im_protocols, u32 tm_protocols) { struct nfcsim *dev = nfc_get_drvdata(nfc_dev); int rc; mutex_lock(&dev->lock); if (dev->polling_mode != NFCSIM_POLL_NONE) { DEV_ERR(dev, "Already in polling mode\n"); rc = -EBUSY; goto exit; } if (im_protocols & NFC_PROTO_NFC_DEP_MASK) dev->polling_mode |= NFCSIM_POLL_INITIATOR; if (tm_protocols & NFC_PROTO_NFC_DEP_MASK) dev->polling_mode |= NFCSIM_POLL_TARGET; if (dev->polling_mode == NFCSIM_POLL_NONE) { DEV_ERR(dev, "Unsupported polling mode\n"); rc = -EINVAL; goto exit; } dev->initiator = 0; dev->curr_polling_mode = NFCSIM_POLL_NONE; queue_delayed_work(wq, &dev->poll_work, 0); DEV_DBG(dev, "Start polling: im: 0x%X, tm: 0x%X\n", im_protocols, tm_protocols); rc = 0; exit: mutex_unlock(&dev->lock); return rc; }
static void pci_dev_init_service(struct device_mem *bar_info, int nr_mapped_bars) { errval_t err; DEV_DEBUG("Initialize device @ [%016lx] with %u bars\n", bar_info->paddr, nr_mapped_bars); if (nr_mapped_bars != 1) { DEV_ERR("number of mapped bars is wrong. Skipping initialization\n"); return; } /* initialize the device */ err = ioat_dma_device_init(*bar_info->frame_cap, &devices[device_count]); if (err_is_fail(err)) { DEV_ERR("Could not initialize the device: %s\n", err_getstring(err)); return; } device_count++; }
static int __init anx7808_init(void) { int ret = -1; if(g_A68_hwID < A80_SR3) goto exit; // MHL solution, so exit myDP driver ret = i2c_add_driver(&anx7808_driver); if (ret < 0) DEV_ERR("%s: failed to register anx7808 i2c drivern", __func__); exit: return ret; }
static int anx7808_system_init(void) { int ret = 0; ret = anx7808_chip_detect(); if (ret == 0) { DEV_ERR("%s : failed to detect anx7808\n", __func__); return -ENODEV; } anx7808_chip_initial(); return 0; }
static void hdmi_tx_put_dt_vreg_data(struct device *dev, struct dss_module_power *module_power) { if (!module_power) { DEV_ERR("%s: invalid input\n", __func__); return; } if (module_power->vreg_config) { devm_kfree(dev, module_power->vreg_config); module_power->vreg_config = NULL; } module_power->num_vreg = 0; } /* hdmi_tx_put_dt_vreg_data */
void msm_dss_iounmap(struct dss_io_data *io_data) { if (!io_data) { DEV_ERR("%pS->%s: invalid input\n", __builtin_return_address(0), __func__); return; } if (io_data->base) { iounmap(io_data->base); io_data->base = NULL; } io_data->len = 0; } /* msm_dss_iounmap */
void dss_reg_w(struct dss_io_data *io, u32 offset, u32 value, u32 debug) { u32 in_val; if (!io || !io->base) { DEV_ERR("%pS->%s: invalid input\n", __builtin_return_address(0), __func__); return; } if (offset > io->len) { DEV_ERR("%pS->%s: offset out of range\n", __builtin_return_address(0), __func__); return; } writel_relaxed(value, io->base + offset); if (debug) { in_val = readl_relaxed(io->base + offset); DEV_DBG("[%08x] => %08x [%08x]\n", (u32)(io->base + offset), value, in_val); } } /* dss_reg_w */