Exemple #1
0
/**
 * wm831x_set_bits: Set the value of a bitfield in a WM831x register
 *
 * @wm831x: Device to write to.
 * @reg: Register to write to.
 * @mask: Mask of bits to set.
 * @val: Value to set (unshifted)
 */
int wm831x_set_bits(struct wm831x *wm831x, unsigned short reg,
		    unsigned short mask, unsigned short val)
{
	int ret;

	mutex_lock(&wm831x->io_lock);

	if (!wm831x_reg_locked(wm831x, reg))
		ret = regmap_update_bits(wm831x->regmap, reg, mask, val);
	else
		ret = -EPERM;

	mutex_unlock(&wm831x->io_lock);

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

	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);

		buf[i] = cpu_to_be16(buf[i]);
	}

	return wm831x->write_dev(wm831x, reg, bytes, src);
}
Exemple #3
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;
}
Exemple #4
0
static bool wm831x_reg_writeable(struct device *dev, unsigned int reg)
{
	struct wm831x *wm831x = dev_get_drvdata(dev);

	if (wm831x_reg_locked(wm831x, reg))
		return false;

	switch (reg) {
	case WM831X_SYSVDD_CONTROL:
	case WM831X_THERMAL_MONITORING:
	case WM831X_POWER_STATE:
	case WM831X_WATCHDOG:
	case WM831X_ON_PIN_CONTROL:
	case WM831X_RESET_CONTROL:
	case WM831X_CONTROL_INTERFACE:
	case WM831X_SECURITY_KEY:
	case WM831X_SOFTWARE_SCRATCH:
	case WM831X_OTP_CONTROL:
	case WM831X_GPIO_LEVEL:
	case WM831X_INTERRUPT_STATUS_1:
	case WM831X_INTERRUPT_STATUS_2:
	case WM831X_INTERRUPT_STATUS_3:
	case WM831X_INTERRUPT_STATUS_4:
	case WM831X_INTERRUPT_STATUS_5:
	case WM831X_IRQ_CONFIG:
	case WM831X_SYSTEM_INTERRUPTS_MASK:
	case WM831X_INTERRUPT_STATUS_1_MASK:
	case WM831X_INTERRUPT_STATUS_2_MASK:
	case WM831X_INTERRUPT_STATUS_3_MASK:
	case WM831X_INTERRUPT_STATUS_4_MASK:
	case WM831X_INTERRUPT_STATUS_5_MASK:
	case WM831X_RTC_TIME_1:
	case WM831X_RTC_TIME_2:
	case WM831X_RTC_ALARM_1:
	case WM831X_RTC_ALARM_2:
	case WM831X_RTC_CONTROL:
	case WM831X_RTC_TRIM:
	case WM831X_TOUCH_CONTROL_1:
	case WM831X_TOUCH_CONTROL_2:
	case WM831X_AUXADC_CONTROL:
	case WM831X_AUXADC_SOURCE:
	case WM831X_COMPARATOR_CONTROL:
	case WM831X_COMPARATOR_1:
	case WM831X_COMPARATOR_2:
	case WM831X_COMPARATOR_3:
	case WM831X_COMPARATOR_4:
	case WM831X_GPIO1_CONTROL:
	case WM831X_GPIO2_CONTROL:
	case WM831X_GPIO3_CONTROL:
	case WM831X_GPIO4_CONTROL:
	case WM831X_GPIO5_CONTROL:
	case WM831X_GPIO6_CONTROL:
	case WM831X_GPIO7_CONTROL:
	case WM831X_GPIO8_CONTROL:
	case WM831X_GPIO9_CONTROL:
	case WM831X_GPIO10_CONTROL:
	case WM831X_GPIO11_CONTROL:
	case WM831X_GPIO12_CONTROL:
	case WM831X_GPIO13_CONTROL:
	case WM831X_GPIO14_CONTROL:
	case WM831X_GPIO15_CONTROL:
	case WM831X_GPIO16_CONTROL:
	case WM831X_CHARGER_CONTROL_1:
	case WM831X_CHARGER_CONTROL_2:
	case WM831X_CHARGER_STATUS:
	case WM831X_BACKUP_CHARGER_CONTROL:
	case WM831X_STATUS_LED_1:
	case WM831X_STATUS_LED_2:
	case WM831X_CURRENT_SINK_1:
	case WM831X_CURRENT_SINK_2:
	case WM831X_DCDC_ENABLE:
	case WM831X_LDO_ENABLE:
	case WM831X_DC1_CONTROL_1:
	case WM831X_DC1_CONTROL_2:
	case WM831X_DC1_ON_CONFIG:
	case WM831X_DC1_SLEEP_CONTROL:
	case WM831X_DC1_DVS_CONTROL:
	case WM831X_DC2_CONTROL_1:
	case WM831X_DC2_CONTROL_2:
	case WM831X_DC2_ON_CONFIG:
	case WM831X_DC2_SLEEP_CONTROL:
	case WM831X_DC2_DVS_CONTROL:
	case WM831X_DC3_CONTROL_1:
	case WM831X_DC3_CONTROL_2:
	case WM831X_DC3_ON_CONFIG:
	case WM831X_DC3_SLEEP_CONTROL:
	case WM831X_DC4_CONTROL:
	case WM831X_DC4_SLEEP_CONTROL:
	case WM831X_EPE1_CONTROL:
	case WM831X_EPE2_CONTROL:
	case WM831X_LDO1_CONTROL:
	case WM831X_LDO1_ON_CONTROL:
	case WM831X_LDO1_SLEEP_CONTROL:
	case WM831X_LDO2_CONTROL:
	case WM831X_LDO2_ON_CONTROL:
	case WM831X_LDO2_SLEEP_CONTROL:
	case WM831X_LDO3_CONTROL:
	case WM831X_LDO3_ON_CONTROL:
	case WM831X_LDO3_SLEEP_CONTROL:
	case WM831X_LDO4_CONTROL:
	case WM831X_LDO4_ON_CONTROL:
	case WM831X_LDO4_SLEEP_CONTROL:
	case WM831X_LDO5_CONTROL:
	case WM831X_LDO5_ON_CONTROL:
	case WM831X_LDO5_SLEEP_CONTROL:
	case WM831X_LDO6_CONTROL:
	case WM831X_LDO6_ON_CONTROL:
	case WM831X_LDO6_SLEEP_CONTROL:
	case WM831X_LDO7_CONTROL:
	case WM831X_LDO7_ON_CONTROL:
	case WM831X_LDO7_SLEEP_CONTROL:
	case WM831X_LDO8_CONTROL:
	case WM831X_LDO8_ON_CONTROL:
	case WM831X_LDO8_SLEEP_CONTROL:
	case WM831X_LDO9_CONTROL:
	case WM831X_LDO9_ON_CONTROL:
	case WM831X_LDO9_SLEEP_CONTROL:
	case WM831X_LDO10_CONTROL:
	case WM831X_LDO10_ON_CONTROL:
	case WM831X_LDO10_SLEEP_CONTROL:
	case WM831X_LDO11_ON_CONTROL:
	case WM831X_LDO11_SLEEP_CONTROL:
	case WM831X_POWER_GOOD_SOURCE_1:
	case WM831X_POWER_GOOD_SOURCE_2:
	case WM831X_CLOCK_CONTROL_1:
	case WM831X_CLOCK_CONTROL_2:
	case WM831X_FLL_CONTROL_1:
	case WM831X_FLL_CONTROL_2:
	case WM831X_FLL_CONTROL_3:
	case WM831X_FLL_CONTROL_4:
	case WM831X_FLL_CONTROL_5:
		return true;
	default:
		return false;
	}
}