Esempio n. 1
0
/* Display proxim data  */
static ssize_t show_proxim_data(struct device *dev,
	struct device_attribute *attr, char *buf)
{
	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
	struct ltr558_chip *chip = iio_priv(indio_dev);
	int prox_data = 0;
	ssize_t buf_count = 0;

	dev_vdbg(dev, "%s()\n", __func__);
	mutex_lock(&chip->lock);

	if (chip->is_prox_enable) {
		prox_data = ltr558_ps_read(chip->client);
		chip->prox_reading = prox_data;
		buf_count = sprintf(buf, "%d\n", prox_data);
	}
	else
		buf_count = sprintf(buf, "%d\n", chip->prox_reading);
	mutex_unlock(&chip->lock);
	return buf_count;
}
static void cyttsp4_log_btn_data(struct cyttsp4_btn_data *bd)
{
	struct device *dev = bd->dev;
	struct cyttsp4_core_data *cd = dev_get_drvdata(dev);
	u8 *pr_buf = cd->pr_buf;
	struct cyttsp4_sysinfo *si = bd->si;
	int cur;
	int t;

	for (cur = 0; cur < si->si_ofs.num_btns; cur++) {
		pr_buf[0] = 0;
		snprintf(pr_buf, CY_MAX_PRBUF_SIZE, "btn_rec[%d]=0x", cur);
		/*for (t = 0; t < si->si_ofs.btn_rec_size; t++)
			snprintf(pr_buf, CY_MAX_PRBUF_SIZE, "%s%02X",
				pr_buf, si->btn_rec_data
				[(cur * si->si_ofs.btn_rec_size) + t]);*/

		dev_vdbg(dev, "%s: %s\n", __func__, pr_buf);
	}
	return;
}
static int cyttsp4_btn_open(struct input_dev *input)
{
	struct device *dev = input->dev.parent;
	struct cyttsp4_core_data *cd = dev_get_drvdata(dev);

	pm_runtime_get_sync(dev);
	cd->number_of_open_input_device++;
	cd->pm_runtime_usage_count++;

	dev_vdbg(dev, "%s: setup subscriptions\n", __func__);

	/* set up touch call back */
	_cyttsp4_subscribe_attention(dev, CY_ATTEN_IRQ, CY_MODULE_BTN,
		cyttsp4_btn_attention, CY_MODE_OPERATIONAL);

	/* set up startup call back */
	_cyttsp4_subscribe_attention(dev, CY_ATTEN_STARTUP, CY_MODULE_BTN,
		cyttsp4_startup_attention, 0);

	return 0;
}
/* read xy_data for all current CapSense button touches */
static int cyttsp4_xy_worker(struct cyttsp4_btn_data *bd)
{
	struct device *dev = &bd->ttsp->dev;
	struct cyttsp4_sysinfo *si = bd->si;
	u8 rep_stat = si->xy_mode[si->si_ofs.rep_ofs + 1];
#ifdef VERBOSE_DEBUG
	int rc;
#endif

	/* rep_data for bad packet check */
	if (IS_BAD_PKT(rep_stat)) {
		dev_dbg(dev, "%s: Invalid buffer detected\n", __func__);
		return 0;
	}

	/* extract button press/release touch information */
	if (si->si_ofs.num_btns > 0) {
		cyttsp4_get_btn_touches(bd);
#ifdef VERBOSE_DEBUG
		/* read button diff data */
		rc = cyttsp4_read(bd->ttsp, CY_MODE_OPERATIONAL,
				si->si_ofs.tt_stat_ofs + 1 +
				si->si_ofs.max_tchs * si->si_ofs.tch_rec_size,
				si->btn_rec_data,
				si->si_ofs.num_btns * si->si_ofs.btn_rec_size);
		if (rc < 0) {
			dev_err(dev, "%s: read fail on button regs r=%d\n",
					__func__, rc);
			return 0;
		}

		/* log button press/release touch information */
		cyttsp4_log_btn_data(bd);
#endif
	}

	dev_vdbg(dev, "%s: done\n", __func__);

	return 0;
}
static int cyttsp5_spi_xfer(u8 op, struct cyttsp5_spi *ts, u8 *buf, int length)
{
	struct device *dev = &ts->client->dev;
	struct spi_message msg;
	struct spi_transfer xfer[2];
	u8 w_header[2];
	u8 r_header[2];
	int rc;

	memset(xfer, 0, sizeof(xfer));

	spi_message_init(&msg);
	cyttsp5_spi_add_rw_msg(&msg, &xfer[0], w_header, r_header, op);

	switch (op) {
	case CY_SPI_RD_OP:
		xfer[1].rx_buf = buf;
		xfer[1].len = length;
		spi_message_add_tail(&xfer[1], &msg);
		break;
	case CY_SPI_WR_OP:
		xfer[1].tx_buf = buf;
		xfer[1].len = length;
		spi_message_add_tail(&xfer[1], &msg);
		break;
	default:
		rc = -EIO;
		goto exit;
	}

	rc = spi_sync(ts->client, &msg);
exit:
	if (rc < 0)
		dev_vdbg(dev, "%s: spi_sync() error %d\n", __func__, rc);

	if (r_header[0] != CY_SPI_SYNC_ACK)
		return -EIO;

	return rc;
}
Esempio n. 6
0
static int ab8500_regulator_set_mode(struct regulator_dev *rdev,
				     unsigned int mode)
{
	int ret = 0;

	struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);

	if (info == NULL) {
		dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
		return -EINVAL;
	}

	switch (mode) {
	case REGULATOR_MODE_NORMAL:
		info->update_val = info->update_val_normal;
		break;
	case REGULATOR_MODE_IDLE:
		info->update_val = info->update_val_idle;
		break;
	default:
		return -EINVAL;
	}

	if (info->is_enabled) {
		ret = abx500_mask_and_set_register_interruptible(info->dev,
			info->update_bank, info->update_reg,
			info->update_mask, info->update_val);
		if (ret < 0)
			dev_err(rdev_get_dev(rdev),
				"couldn't set regulator mode\n");

		dev_vdbg(rdev_get_dev(rdev),
			"%s-set_mode (bank, reg, mask, value): "
			"0x%x, 0x%x, 0x%x, 0x%x\n",
			info->desc.name, info->update_bank, info->update_reg,
			info->update_mask, info->update_val);
	}

	return ret;
}
static int exynos_drd_switch_start_peripheral(struct usb_otg *otg, int on)
{
	int ret;

	if (!otg->gadget)
		return -EINVAL;

	dev_dbg(otg->phy->dev, "Turn %s gadget %s\n",
			on ? "on" : "off", otg->gadget->name);

	/* Samsung KOR S/W GROUP kmato.kim for MDM*/
	if (is_usb_locked) {
		ret = usb_gadget_vbus_disconnect(otg->gadget);
		pr_info("%s: Becuase MDM abnomal deleted, usb vbus disconnect \n",
			__func__);
		return ret;
	}

	if (on) {
		/* Start device only if host is off */
		if (!exynos_drd_switch_is_host_off(otg)) {
			/*
			 * REVISIT: if host is not suspended shall we check
			 * runtime_error flag and clear it, if it is set?
			 * It will give an additional chance to the host
			 * to be suspended if runtime error happened.
			 */
			dev_vdbg(otg->phy->dev, "%s: host is still active\n",
						__func__);
			return -EAGAIN;
		}

		ret = usb_gadget_vbus_connect(otg->gadget);
	} else {
		ret = usb_gadget_vbus_disconnect(otg->gadget);
		/* Currently always return 0 */
	}

	return ret;
}
static void cyttsp4_mt_process_touch(struct cyttsp4_mt_data *md,
	struct cyttsp4_touch *touch)
{
	struct device *dev = md->dev;
	int tmp;
	bool flipped;

	if (md->pdata->flags & CY_MT_FLAG_FLIP) {
		tmp = touch->abs[CY_TCH_X];
		touch->abs[CY_TCH_X] = touch->abs[CY_TCH_Y];
		touch->abs[CY_TCH_Y] = tmp;
		flipped = true;
	} else
		flipped = false;

	if (md->pdata->flags & CY_MT_FLAG_INV_X) {
		if (flipped)
			touch->abs[CY_TCH_X] = md->si->si_ofs.max_y -
				touch->abs[CY_TCH_X];
		else
			touch->abs[CY_TCH_X] = md->si->si_ofs.max_x -
				touch->abs[CY_TCH_X];
	}
	if (md->pdata->flags & CY_MT_FLAG_INV_Y) {
		if (flipped)
			touch->abs[CY_TCH_Y] = md->si->si_ofs.max_x -
				touch->abs[CY_TCH_Y];
		else
			touch->abs[CY_TCH_Y] = md->si->si_ofs.max_y -
				touch->abs[CY_TCH_Y];
	}

	dev_vdbg(dev, "%s: flip=%s inv-x=%s inv-y=%s x=%04X(%d) y=%04X(%d)\n",
		__func__, flipped ? "true" : "false",
		md->pdata->flags & CY_MT_FLAG_INV_X ? "true" : "false",
		md->pdata->flags & CY_MT_FLAG_INV_Y ? "true" : "false",
		touch->abs[CY_TCH_X], touch->abs[CY_TCH_X],
		touch->abs[CY_TCH_Y], touch->abs[CY_TCH_Y]);
}
Esempio n. 9
0
static int ux500_pd_amba_runtime_idle(struct device *dev)
{
	int (*callback)(struct device *) = NULL;
	int ret;

	dev_vdbg(dev, "%s()\n", __func__);

	/*
	 * Do not bypass AMBA bus runtime functions by calling generic runtime
	 * directly. A future fix could be to implement a
	 * "pm_bus_generic_runtime_*" API which we can use instead.
	 */
	if (dev->bus && dev->bus->pm)
		callback = dev->bus->pm->runtime_idle;

	if (callback)
		ret = callback(dev);
	else
		ret = pm_generic_runtime_idle(dev);

	return ret;
}
static int exynos_drd_switch_start_peripheral(struct usb_otg *otg, int on)
{
	int ret;

	if (!otg->gadget)
		return -EINVAL;

	dev_dbg(otg->phy->dev, "Turn %s gadget %s\n",
			on ? "on" : "off", otg->gadget->name);

#ifdef CONFIG_TARGET_LOCALE_KOR
	if (is_usb_locked) {
		ret = usb_gadget_vbus_disconnect(otg->gadget);
		return ret;
	}
#endif

	if (on) {
		/* Start device only if host is off */
		if (!exynos_drd_switch_is_host_off(otg)) {
			/*
			 * REVISIT: if host is not suspended shall we check
			 * runtime_error flag and clear it, if it is set?
			 * It will give an additional chance to the host
			 * to be suspended if runtime error happened.
			 */
			dev_vdbg(otg->phy->dev, "%s: host is still active\n",
						__func__);
			return -EAGAIN;
		}

		ret = usb_gadget_vbus_connect(otg->gadget);
	} else {
		ret = usb_gadget_vbus_disconnect(otg->gadget);
		/* Currently always return 0 */
	}

	return ret;
}
Esempio n. 11
0
static int wm831x_write(struct wm831x *wm831x, unsigned short reg,
			int bytes, void *src)
{
	u16 *buf = src;
	int i, ret;

	BUG_ON(bytes % 2);
	BUG_ON(bytes <= 0);

	for (i = 0; i < bytes / 2; i++) {
		if (wm831x_reg_locked(wm831x, reg))
			return -EPERM;

		dev_vdbg(wm831x->dev, "Write %04x to R%d(0x%x)\n",
			 buf[i], reg + i, reg + i);
		ret = regmap_write(wm831x->regmap, reg + i, buf[i]);
		if (ret != 0)
			return ret;
	}

	return 0;
}
static ssize_t cyttsp5_command_store(struct device *dev,
		struct device_attribute *attr, const char *buf, size_t size)
{
	struct cyttsp5_device_access_data *dad
		= cyttsp5_get_device_access_data(dev);
	ssize_t length;
	int rc;

	mutex_lock(&dad->sysfs_lock);
	dad->status = 0;
	dad->response_length = 0;
	length = cyttsp5_ic_parse_input(dev, buf, size, dad->ic_buf,
			CY_MAX_PRBUF_SIZE);
	if (length <= 0) {
		dev_err(dev, "%s: %s Group Data store\n", __func__,
				"Malformed input for");
		goto exit;
	}

	/* write ic_buf to log */
	cyttsp5_pr_buf(dev, dad->pr_buf, dad->ic_buf, length, "ic_buf");

	//pm_runtime_get_sync(dev);
	rc = cmd->cmd->user_cmd(dev, 1, CY_MAX_PRBUF_SIZE,
			dad->response_buf, length, dad->ic_buf,
			&dad->response_length);
	//pm_runtime_put(dev);
	if (rc) {
		dad->response_length = 0;
		dev_err(dev, "%s: Failed to store command\n", __func__);
	} else {
		dad->status = 1;
	}

exit:
	mutex_unlock(&dad->sysfs_lock);
	dev_vdbg(dev, "%s: return size=%d\n", __func__, size);
	return size;
}
Esempio n. 13
0
static int acm_submit_read_urb(struct acm *acm, int index, gfp_t mem_flags)
{
	int res;

	if (!test_and_clear_bit(index, &acm->read_urbs_free))
		return 0;

	dev_vdbg(&acm->data->dev, "%s - urb %d\n", __func__, index);

	res = usb_submit_urb(acm->read_urbs[index], mem_flags);
	if (res) {
		if (res != -EPERM) {
			dev_err(&acm->data->dev,
					"%s - usb_submit_urb failed: %d\n",
					__func__, res);
		}
		set_bit(index, &acm->read_urbs_free);
		return res;
	}

	return 0;
}
static ssize_t store_als_persist(struct device *dev,
		struct device_attribute *attr, const char *buf, size_t count)
{
	struct iio_dev *indio_dev = dev_get_drvdata(dev);
	struct isl29028_chip *chip = iio_priv(indio_dev);
	unsigned long lval;

	dev_vdbg(dev, "%s()\n", __func__);

	if (strict_strtoul(buf, 10, &lval))
		return -EINVAL;

	if ((lval > 16) || (lval < 0x0)) {
		dev_err(dev, "The als persist is not supported\n");
		return -EINVAL;
	}

	mutex_lock(&chip->lock);
	chip->als_persist = (int)lval;
	mutex_unlock(&chip->lock);
	return count;
}
Esempio n. 15
0
static int adf7242_set_txpower(struct ieee802154_hw *hw, int mbm)
{
    struct adf7242_local *lp = hw->priv;
    u8 pwr, bias_ctrl, dbias, tmp;
    int db = mbm / 100;

    dev_vdbg(&lp->spi->dev, "%s : Power %d dB\n", __func__, db);

    if (db > 5 || db < -26)
        return -EINVAL;

    db = DIV_ROUND_CLOSEST(db + 29, 2);

    if (db > 15) {
        dbias = PA_DBIAS_HIGH_POWER;
        bias_ctrl = PA_BIAS_HIGH_POWER;
    } else {
        dbias = PA_DBIAS_LOW_POWER;
        bias_ctrl = PA_BIAS_LOW_POWER;
    }

    pwr = clamp_t(u8, db, 3, 15);

    adf7242_read_reg(lp, REG_PA_CFG, &tmp);
    tmp &= ~PA_BRIDGE_DBIAS(~0);
    tmp |= PA_BRIDGE_DBIAS(dbias);
    adf7242_write_reg(lp, REG_PA_CFG, tmp);

    adf7242_read_reg(lp, REG_PA_BIAS, &tmp);
    tmp &= ~PA_BIAS_CTRL(~0);
    tmp |= PA_BIAS_CTRL(bias_ctrl);
    adf7242_write_reg(lp, REG_PA_BIAS, tmp);

    adf7242_read_reg(lp, REG_EXTPA_MSC, &tmp);
    tmp &= ~PA_PWR(~0);
    tmp |= PA_PWR(pwr);

    return adf7242_write_reg(lp, REG_EXTPA_MSC, tmp);
}
static int wm8994_read(struct wm8994 *wm8994, unsigned short reg,
		       int bytes, void *dest)
{
	int ret, i;
	u16 *buf = dest;

	BUG_ON(bytes % 2);
	BUG_ON(bytes <= 0);

	ret = wm8994->read_dev(wm8994, reg, bytes, dest);
	if (ret < 0)
		return ret;

	for (i = 0; i < bytes / 2; i++) {
		buf[i] = be16_to_cpu(buf[i]);

		dev_vdbg(wm8994->dev, "Read %04x from R%d(0x%x)\n",
			 buf[i], reg + i, reg + i);
	}

	return 0;
}
static s32 cyttsp4_spi_write_block_data(struct cyttsp4_spi *ts, u16 addr,
				int length, const void *data, int max_xfer)
{
	int rc = -EINVAL;
	int retry = 0;
	int trans_len;
	struct device *dev = &ts->client->dev;

	dev_vdbg(dev, "%s: Enter\n", __func__);

	while (length > 0) {
		trans_len = min(length, max_xfer);

		rc = cyttsp4_spi_xfer(CY_SPI_WR_OP, ts, addr, (void *)data,
				trans_len);
		if (rc < 0) {
			dev_err(dev, "%s: Fail write r=%d\n", __func__, rc);
			goto exit;
		} else if (rc > 0) {
			/* Perform retry or fail */
			if (retry++ < CY_SPI_NUM_RETRY) {
				dev_dbg(dev, "%s: ACK error, retry %d\n",
					__func__, retry);
				continue;
			} else {
				dev_err(dev, "%s: ACK error\n", __func__);
				rc = -EIO;
				goto exit;
			}
		}

		length -= trans_len;
		data += trans_len;
		addr += trans_len;
	}
exit:
	return rc;
}
Esempio n. 18
0
int dwc3_gadget_ep0_queue(struct usb_ep *ep, struct usb_request *request,
		gfp_t gfp_flags)
{
	struct dwc3_request		*req = to_dwc3_request(request);
	struct dwc3_ep			*dep = to_dwc3_ep(ep);
	struct dwc3			*dwc = dep->dwc;

	unsigned long			flags;

	int				ret;

	spin_lock_irqsave(&dwc->lock, flags);
	if (!dep->desc) {
		dev_dbg(dwc->dev, "trying to queue request %p to disabled %s\n",
				request, dep->name);
		ret = -ESHUTDOWN;
		goto out;
	}

	/* we share one TRB for ep0/1 */
	if (!list_empty(&dwc->eps[0]->request_list) ||
			!list_empty(&dwc->eps[1]->request_list) ||
			dwc->ep0_status_pending) {
		ret = -EBUSY;
		goto out;
	}

	dev_vdbg(dwc->dev, "queueing request %p to %s length %d, state '%s'\n",
			request, dep->name, request->length,
			dwc3_ep0_state_string(dwc->ep0state));

	ret = __dwc3_gadget_ep0_queue(dep, req);

out:
	spin_unlock_irqrestore(&dwc->lock, flags);

	return ret;
}
Esempio n. 19
0
static int delta_mjpeg_ipc_open(struct delta_ctx *pctx)
{
	struct delta_dev *delta = pctx->dev;
	struct delta_mjpeg_ctx *ctx = to_ctx(pctx);
	int ret = 0;
	struct jpeg_video_decode_init_params_t params_struct;
	struct jpeg_video_decode_init_params_t *params = &params_struct;
	struct delta_buf *ipc_buf;
	u32 ipc_buf_size;
	struct delta_ipc_param ipc_param;
	void *hdl;

	memset(params, 0, sizeof(*params));
	params->circular_buffer_begin_addr_p = 0x00000000;
	params->circular_buffer_end_addr_p = 0xffffffff;

	dev_vdbg(delta->dev,
		 "%s  %s\n", pctx->name,
		 ipc_open_param_str(params, ctx->str, sizeof(ctx->str)));

	ipc_param.size = sizeof(*params);
	ipc_param.data = params;
	ipc_buf_size = sizeof(struct jpeg_decode_params_t) +
	    sizeof(struct jpeg_decode_return_params_t);
	ret = delta_ipc_open(pctx, "JPEG_DECODER_HW0", &ipc_param,
			     ipc_buf_size, &ipc_buf, &hdl);
	if (ret) {
		dev_err(delta->dev,
			"%s  dumping command %s\n", pctx->name,
			ipc_open_param_str(params, ctx->str, sizeof(ctx->str)));
		return ret;
	}

	ctx->ipc_buf = ipc_buf;
	ctx->ipc_hdl = hdl;

	return 0;
}
/**
 * exynos_drd_switch_handle_id - handle ID pin state.
 *
 * @drd_switch: Pointer to the DRD switch structure.
 * @id_state: ID pin state.
 */
static void exynos_drd_switch_handle_id(struct exynos_drd_switch *drd_switch,
                                        enum id_pin_state id_state)
{
    struct device *dev = drd_switch->otg.phy->dev;
    unsigned long flags;
    int res;

    spin_lock_irqsave(&drd_switch->lock, flags);

    if (id_state != drd_switch->id_state) {
        drd_switch->id_state = id_state;
        /*
         * Debouncing: timer will not expire untill
         * ID state is stable.
         */
        res = mod_timer(&drd_switch->id_db_timer,
                        jiffies + ID_DEBOUNCE_DELAY);
        if (res == 1)
            dev_vdbg(dev, "id debouncing ...\n");
    }

    spin_unlock_irqrestore(&drd_switch->lock, flags);
}
Esempio n. 21
0
static int db8500_regulator_switch_disable(struct regulator_dev *rdev)
{
	struct db8500_regulator_info *info = rdev_get_drvdata(rdev);
	int ret;

	if (info == NULL)
		return -EINVAL;

	dev_vdbg(rdev_get_dev(rdev), "regulator-switch-%s-disable\n",
		info->desc.name);

	ret = disable_epod(info->epod_id, info->is_ramret);
	if (ret < 0) {
		dev_err(rdev_get_dev(rdev),
			"regulator_switch-%s-disable: prcmu call failed\n",
			info->desc.name);
		goto out;
	}

	info->is_enabled = 0;
out:
	return ret;
}
/* Display IR data  */
static ssize_t show_ir_data(struct device *dev,
	struct device_attribute *attr, char *buf)
{
	struct iio_dev *indio_dev = dev_get_drvdata(dev);
	struct isl29028_chip *chip = iio_priv(indio_dev);
	int als_ir_data;
	bool st;
	ssize_t buf_count = 0;

	dev_vdbg(dev, "%s()\n", __func__);
	mutex_lock(&chip->lock);

	if (chip->als_ir_mode == MODE_IR) {
		st = isl29028_read_als_ir(chip->client, &als_ir_data);
		if (st) {
			buf_count = sprintf(buf, "%d\n", als_ir_data);
			chip->ir_reading = als_ir_data;
		}
	} else
		buf_count = sprintf(buf, "%d\n", chip->ir_reading);
	mutex_unlock(&chip->lock);
	return buf_count;
}
static int cyttsp4_setup_input_device(struct device *dev)
{
	struct cyttsp4_core_data *cd = dev_get_drvdata(dev);
	struct cyttsp4_btn_data *bd = &cd->bd;
	int i;
	int rc;

	dev_vdbg(dev, "%s: Initialize event signals\n", __func__);
	__set_bit(EV_KEY, bd->input->evbit);
    __set_bit(EV_LED, bd->input->evbit);
	__set_bit(LED_MISC, bd->input->ledbit);
	for (i = 0; i < bd->si->si_ofs.num_btns; i++)
		__set_bit(bd->si->btn[i].key_code, bd->input->keybit);

	rc = input_register_device(bd->input);
	if (rc < 0)
		dev_err(dev, "%s: Error, failed register input device r=%d\n",
			__func__, rc);
	else
		bd->input_device_registered = true;

	return rc;
}
Esempio n. 24
0
static s32 cyttsp4_spi_write_block_data(struct cyttsp4_spi *ts, u8 addr,
                                        size_t length, const void *data)
{
    int rc = 0;
    struct device *dev = &ts->client->dev;

    dev_vdbg(dev, "%s: Enter\n", __func__);

    rc = cyttsp4_spi_xfer(CY_SPI_WR_OP, ts, addr, (void *)data, length);
    if (rc < 0) {
        dev_err(dev, "%s: Fail write r=%d\n", __func__, rc);
        /*
         * Do not print the above error if the data sync bytes
         * were not found.
         * This is a normal condition for the bootloader loader
         * startup and need to retry until data sync bytes are found.
         */
    } else if (rc > 0)
        /* Now signal fail; so retry can be done */
        rc = -EIO;

    return rc;
}
Esempio n. 25
0
/**
 * omap_control_usb_set_mode - Calls to functions to set USB in one of host mode
 * or device mode or to denote disconnected state
 * @dev: the control module device
 * @mode: The mode to which usb should be configured
 *
 * This is an API to write to the mailbox register to notify the usb core that
 * a usb device has been connected.
 */
void omap_control_usb_set_mode(struct device *dev,
	enum omap_control_usb_mode mode)
{
	struct omap_control_usb	*ctrl_usb;

	if (IS_ERR(dev) || control_usb->type != OMAP_CTRL_DEV_TYPE1)
		return;

	ctrl_usb = dev_get_drvdata(dev);

	switch (mode) {
	case USB_MODE_HOST:
		omap_control_usb_host_mode(ctrl_usb);
		break;
	case USB_MODE_DEVICE:
		omap_control_usb_device_mode(ctrl_usb);
		break;
	case USB_MODE_DISCONNECT:
		omap_control_usb_set_sessionend(ctrl_usb);
		break;
	default:
		dev_vdbg(dev, "invalid omap control usb mode\n");
	}
}
Esempio n. 26
0
static int ux500_pd_resume_noirq(struct device *dev)
{
	struct pm_runtime_data *prd = __to_prd(dev);

	dev_vdbg(dev, "%s()\n", __func__);

	/* Only handle devices that use runtime pm */
	if (!prd || !test_bit(BIT_ONCE, &prd->flags))
		return 0;

	/*
	 * Already was runtime suspended?  No need to resume here, runtime
	 * resume will take care of it.
	 */
	if (pm_runtime_status_suspended(dev))
		return 0;

	/*
	 * We get here only if the device was not runtime suspended,
	 * but we forced it down in suspend_noirq above.  Bring it
	 * up since pm-runtime thinks it is not suspended.
	 */
	return ux500_pd_runtime_resume(dev);
}
/* Display proxim data  */
static ssize_t show_proxim_data(struct device *dev,
	struct device_attribute *attr, char *buf)
{
	struct iio_dev *indio_dev = dev_get_drvdata(dev);
	struct isl29028_chip *chip = iio_priv(indio_dev);
	int prox_data;
	bool st;
	ssize_t buf_count = 0;

	dev_vdbg(dev, "%s()\n", __func__);
	mutex_lock(&chip->lock);

	if (chip->is_prox_enable) {
		st = isl29028_read_proxim(chip->client, &prox_data);
		if (st) {
			buf_count = sprintf(buf, "%d\n", prox_data);
			chip->prox_reading = prox_data;
		}
	} else
		buf_count = sprintf(buf, "%d\n", chip->prox_reading);

	mutex_unlock(&chip->lock);
	return buf_count;
}
Esempio n. 28
0
static int ab8500_regulator_disable(struct regulator_dev *rdev)
{
    int ret;
    struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);

    if (info == NULL) {
        dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
        return -EINVAL;
    }

    ret = abx500_mask_and_set_register_interruptible(info->dev,
            info->update_bank, info->update_reg,
            info->update_mask, 0x0);
    if (ret < 0)
        dev_err(rdev_get_dev(rdev),
                "couldn't set disable bits for regulator\n");

    dev_vdbg(rdev_get_dev(rdev),
             "%s-disable (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n",
             info->desc.name, info->update_bank, info->update_reg,
             info->update_mask, 0x0);

    return ret;
}
/* Switch off the clock of the uart controller. */
void tegra_uart_request_clock_off(struct uart_port *uport)
{
	unsigned long flags;
	struct tegra_uart_port *t;
	bool is_clk_disable = false;

	if (IS_ERR_OR_NULL(uport))
		BUG();

	dev_vdbg(uport->dev, "tegra_uart_request_clock_off");

	t = container_of(uport, struct tegra_uart_port, uport);
	spin_lock_irqsave(&uport->lock, flags);
	if (t->uart_state == TEGRA_UART_OPENED) {
		is_clk_disable = true;
		t->uart_state = TEGRA_UART_CLOCK_OFF;
	}
	spin_unlock_irqrestore(&uport->lock, flags);

	if (is_clk_disable)
		clk_disable(t->clk);

	return;
}
Esempio n. 30
0
static int isl29018_read_sensor_input(struct i2c_client *client, int mode)
{
	int status;
	int lux;

	/* Set mode */
	status = isl29018_write_data(client, ISL29018_REG_ADD_COMMAND1,
			mode, COMMMAND1_OPMODE_MASK, COMMMAND1_OPMODE_SHIFT);
	if (status) {
		dev_err(&client->dev, "Error in setting operating mode\n");
		return status;
	}
	integration_wait(iio_priv(i2c_get_clientdata(client)));
	status = i2c_smbus_read_word_data(client, ISL29018_REG_ADD_DATA_LSB);
	if (status < 0) {
		dev_err(&client->dev, "Error in reading Lux DATA\n");
		return status;
	}

	lux = le16_to_cpu(status);
	dev_vdbg(&client->dev, "lux = %u\n", lux);

	return lux;
}