wm8994-core.c 15.0 KB
Newer Older
M
Mark Brown 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/*
 * wm8994-core.c  --  Device access for Wolfson WM8994
 *
 * Copyright 2009 Wolfson Microelectronics PLC.
 *
 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
 *
 *  This program is free software; you can redistribute  it and/or modify it
 *  under  the terms of  the GNU General  Public License as published by the
 *  Free Software Foundation;  either version 2 of the  License, or (at your
 *  option) any later version.
 *
 */

#include <linux/kernel.h>
#include <linux/module.h>
17
#include <linux/slab.h>
M
Mark Brown 已提交
18 19 20
#include <linux/i2c.h>
#include <linux/delay.h>
#include <linux/mfd/core.h>
21
#include <linux/pm_runtime.h>
M
Mark Brown 已提交
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
#include <linux/regulator/consumer.h>
#include <linux/regulator/machine.h>

#include <linux/mfd/wm8994/core.h>
#include <linux/mfd/wm8994/pdata.h>
#include <linux/mfd/wm8994/registers.h>

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++) {
		dev_vdbg(wm8994->dev, "Read %04x from R%d(0x%x)\n",
44
			 be16_to_cpu(buf[i]), reg + i, reg + i);
M
Mark Brown 已提交
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
	}

	return 0;
}

/**
 * wm8994_reg_read: Read a single WM8994 register.
 *
 * @wm8994: Device to read from.
 * @reg: Register to read.
 */
int wm8994_reg_read(struct wm8994 *wm8994, unsigned short reg)
{
	unsigned short val;
	int ret;

	mutex_lock(&wm8994->io_lock);

	ret = wm8994_read(wm8994, reg, 2, &val);

	mutex_unlock(&wm8994->io_lock);

	if (ret < 0)
		return ret;
	else
70
		return be16_to_cpu(val);
M
Mark Brown 已提交
71 72 73 74 75 76 77 78 79
}
EXPORT_SYMBOL_GPL(wm8994_reg_read);

/**
 * wm8994_bulk_read: Read multiple WM8994 registers
 *
 * @wm8994: Device to read from
 * @reg: First register
 * @count: Number of registers
80
 * @buf: Buffer to fill.  The data will be returned big endian.
M
Mark Brown 已提交
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
 */
int wm8994_bulk_read(struct wm8994 *wm8994, unsigned short reg,
		     int count, u16 *buf)
{
	int ret;

	mutex_lock(&wm8994->io_lock);

	ret = wm8994_read(wm8994, reg, count * 2, buf);

	mutex_unlock(&wm8994->io_lock);

	return ret;
}
EXPORT_SYMBOL_GPL(wm8994_bulk_read);

static int wm8994_write(struct wm8994 *wm8994, unsigned short reg,
M
Mark Brown 已提交
98
			int bytes, const void *src)
M
Mark Brown 已提交
99
{
M
Mark Brown 已提交
100
	const u16 *buf = src;
M
Mark Brown 已提交
101 102 103 104 105 106 107
	int i;

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

	for (i = 0; i < bytes / 2; i++) {
		dev_vdbg(wm8994->dev, "Write %04x to R%d(0x%x)\n",
108
			 be16_to_cpu(buf[i]), reg + i, reg + i);
M
Mark Brown 已提交
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
	}

	return wm8994->write_dev(wm8994, reg, bytes, src);
}

/**
 * wm8994_reg_write: Write a single WM8994 register.
 *
 * @wm8994: Device to write to.
 * @reg: Register to write to.
 * @val: Value to write.
 */
int wm8994_reg_write(struct wm8994 *wm8994, unsigned short reg,
		     unsigned short val)
{
	int ret;

126 127
	val = cpu_to_be16(val);

M
Mark Brown 已提交
128 129 130 131 132 133 134 135 136 137
	mutex_lock(&wm8994->io_lock);

	ret = wm8994_write(wm8994, reg, 2, &val);

	mutex_unlock(&wm8994->io_lock);

	return ret;
}
EXPORT_SYMBOL_GPL(wm8994_reg_write);

138 139 140 141 142 143
/**
 * wm8994_bulk_write: Write multiple WM8994 registers
 *
 * @wm8994: Device to write to
 * @reg: First register
 * @count: Number of registers
144
 * @buf: Buffer to write from.  Data must be big-endian formatted.
145 146
 */
int wm8994_bulk_write(struct wm8994 *wm8994, unsigned short reg,
M
Mark Brown 已提交
147
		      int count, const u16 *buf)
148 149 150 151 152 153 154 155 156 157 158 159 160
{
	int ret;

	mutex_lock(&wm8994->io_lock);

	ret = wm8994_write(wm8994, reg, count * 2, buf);

	mutex_unlock(&wm8994->io_lock);

	return ret;
}
EXPORT_SYMBOL_GPL(wm8994_bulk_write);

M
Mark Brown 已提交
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
/**
 * wm8994_set_bits: Set the value of a bitfield in a WM8994 register
 *
 * @wm8994: Device to write to.
 * @reg: Register to write to.
 * @mask: Mask of bits to set.
 * @val: Value to set (unshifted)
 */
int wm8994_set_bits(struct wm8994 *wm8994, unsigned short reg,
		    unsigned short mask, unsigned short val)
{
	int ret;
	u16 r;

	mutex_lock(&wm8994->io_lock);

	ret = wm8994_read(wm8994, reg, 2, &r);
	if (ret < 0)
		goto out;

181 182
	r = be16_to_cpu(r);

M
Mark Brown 已提交
183 184 185
	r &= ~mask;
	r |= val;

186 187
	r = cpu_to_be16(r);

M
Mark Brown 已提交
188 189 190 191 192 193 194 195 196 197
	ret = wm8994_write(wm8994, reg, 2, &r);

out:
	mutex_unlock(&wm8994->io_lock);

	return ret;
}
EXPORT_SYMBOL_GPL(wm8994_set_bits);

static struct mfd_cell wm8994_regulator_devs[] = {
198 199 200 201 202 203 204 205 206 207
	{
		.name = "wm8994-ldo",
		.id = 1,
		.pm_runtime_no_callbacks = true,
	},
	{
		.name = "wm8994-ldo",
		.id = 2,
		.pm_runtime_no_callbacks = true,
	},
M
Mark Brown 已提交
208 209
};

210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225
static struct resource wm8994_codec_resources[] = {
	{
		.start = WM8994_IRQ_TEMP_SHUT,
		.end   = WM8994_IRQ_TEMP_WARN,
		.flags = IORESOURCE_IRQ,
	},
};

static struct resource wm8994_gpio_resources[] = {
	{
		.start = WM8994_IRQ_GPIO(1),
		.end   = WM8994_IRQ_GPIO(11),
		.flags = IORESOURCE_IRQ,
	},
};

M
Mark Brown 已提交
226
static struct mfd_cell wm8994_devs[] = {
227 228 229 230 231 232 233 234 235 236
	{
		.name = "wm8994-codec",
		.num_resources = ARRAY_SIZE(wm8994_codec_resources),
		.resources = wm8994_codec_resources,
	},

	{
		.name = "wm8994-gpio",
		.num_resources = ARRAY_SIZE(wm8994_gpio_resources),
		.resources = wm8994_gpio_resources,
237
		.pm_runtime_no_callbacks = true,
238
	},
M
Mark Brown 已提交
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255
};

/*
 * Supplies for the main bulk of CODEC; the LDO supplies are ignored
 * and should be handled via the standard regulator API supply
 * management.
 */
static const char *wm8994_main_supplies[] = {
	"DBVDD",
	"DCVDD",
	"AVDD1",
	"AVDD2",
	"CPVDD",
	"SPKVDD1",
	"SPKVDD2",
};

M
Mark Brown 已提交
256 257 258 259 260 261 262 263 264 265 266 267
static const char *wm8958_main_supplies[] = {
	"DBVDD1",
	"DBVDD2",
	"DBVDD3",
	"DCVDD",
	"AVDD1",
	"AVDD2",
	"CPVDD",
	"SPKVDD1",
	"SPKVDD2",
};

M
Mark Brown 已提交
268
#ifdef CONFIG_PM
269
static int wm8994_suspend(struct device *dev)
M
Mark Brown 已提交
270 271 272 273
{
	struct wm8994 *wm8994 = dev_get_drvdata(dev);
	int ret;

274 275 276 277 278 279 280 281 282 283
	/* Don't actually go through with the suspend if the CODEC is
	 * still active (eg, for audio passthrough from CP. */
	ret = wm8994_reg_read(wm8994, WM8994_POWER_MANAGEMENT_1);
	if (ret < 0) {
		dev_err(dev, "Failed to read power status: %d\n", ret);
	} else if (ret & WM8994_VMID_SEL_MASK) {
		dev_dbg(dev, "CODEC still active, ignoring suspend\n");
		return 0;
	}

M
Mark Brown 已提交
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298
	/* GPIO configuration state is saved here since we may be configuring
	 * the GPIO alternate functions even if we're not using the gpiolib
	 * driver for them.
	 */
	ret = wm8994_read(wm8994, WM8994_GPIO_1, WM8994_NUM_GPIO_REGS * 2,
			  &wm8994->gpio_regs);
	if (ret < 0)
		dev_err(dev, "Failed to save GPIO registers: %d\n", ret);

	/* For similar reasons we also stash the regulator states */
	ret = wm8994_read(wm8994, WM8994_LDO_1, WM8994_NUM_LDO_REGS * 2,
			  &wm8994->ldo_regs);
	if (ret < 0)
		dev_err(dev, "Failed to save LDO registers: %d\n", ret);

299 300 301 302 303
	/* Explicitly put the device into reset in case regulators
	 * don't get disabled in order to ensure consistent restart.
	 */
	wm8994_reg_write(wm8994, WM8994_SOFTWARE_RESET, 0x8994);

304 305
	wm8994->suspended = true;

M
Mark Brown 已提交
306
	ret = regulator_bulk_disable(wm8994->num_supplies,
M
Mark Brown 已提交
307 308 309 310 311 312 313 314 315
				     wm8994->supplies);
	if (ret != 0) {
		dev_err(dev, "Failed to disable supplies: %d\n", ret);
		return ret;
	}

	return 0;
}

316
static int wm8994_resume(struct device *dev)
M
Mark Brown 已提交
317 318 319 320
{
	struct wm8994 *wm8994 = dev_get_drvdata(dev);
	int ret;

321 322 323 324
	/* We may have lied to the PM core about suspending */
	if (!wm8994->suspended)
		return 0;

M
Mark Brown 已提交
325
	ret = regulator_bulk_enable(wm8994->num_supplies,
M
Mark Brown 已提交
326 327 328 329 330 331
				    wm8994->supplies);
	if (ret != 0) {
		dev_err(dev, "Failed to enable supplies: %d\n", ret);
		return ret;
	}

332 333 334 335 336
	ret = wm8994_write(wm8994, WM8994_INTERRUPT_STATUS_1_MASK,
			   WM8994_NUM_IRQ_REGS * 2, &wm8994->irq_masks_cur);
	if (ret < 0)
		dev_err(dev, "Failed to restore interrupt masks: %d\n", ret);

M
Mark Brown 已提交
337 338 339 340 341 342 343 344 345 346
	ret = wm8994_write(wm8994, WM8994_LDO_1, WM8994_NUM_LDO_REGS * 2,
			   &wm8994->ldo_regs);
	if (ret < 0)
		dev_err(dev, "Failed to restore LDO registers: %d\n", ret);

	ret = wm8994_write(wm8994, WM8994_GPIO_1, WM8994_NUM_GPIO_REGS * 2,
			   &wm8994->gpio_regs);
	if (ret < 0)
		dev_err(dev, "Failed to restore GPIO registers: %d\n", ret);

347 348
	wm8994->suspended = false;

M
Mark Brown 已提交
349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377
	return 0;
}
#endif

#ifdef CONFIG_REGULATOR
static int wm8994_ldo_in_use(struct wm8994_pdata *pdata, int ldo)
{
	struct wm8994_ldo_pdata *ldo_pdata;

	if (!pdata)
		return 0;

	ldo_pdata = &pdata->ldo[ldo];

	if (!ldo_pdata->init_data)
		return 0;

	return ldo_pdata->init_data->num_consumer_supplies != 0;
}
#else
static int wm8994_ldo_in_use(struct wm8994_pdata *pdata, int ldo)
{
	return 0;
}
#endif

/*
 * Instantiate the generic non-control parts of the device.
 */
M
Mark Brown 已提交
378
static int wm8994_device_init(struct wm8994 *wm8994, int irq)
M
Mark Brown 已提交
379 380
{
	struct wm8994_pdata *pdata = wm8994->dev->platform_data;
M
Mark Brown 已提交
381
	const char *devname;
M
Mark Brown 已提交
382 383 384 385 386 387 388 389 390 391 392 393 394 395 396
	int ret, i;

	mutex_init(&wm8994->io_lock);
	dev_set_drvdata(wm8994->dev, wm8994);

	/* Add the on-chip regulators first for bootstrapping */
	ret = mfd_add_devices(wm8994->dev, -1,
			      wm8994_regulator_devs,
			      ARRAY_SIZE(wm8994_regulator_devs),
			      NULL, 0);
	if (ret != 0) {
		dev_err(wm8994->dev, "Failed to add children: %d\n", ret);
		goto err;
	}

M
Mark Brown 已提交
397 398 399 400 401 402 403 404 405 406 407 408
	switch (wm8994->type) {
	case WM8994:
		wm8994->num_supplies = ARRAY_SIZE(wm8994_main_supplies);
		break;
	case WM8958:
		wm8994->num_supplies = ARRAY_SIZE(wm8958_main_supplies);
		break;
	default:
		BUG();
		return -EINVAL;
	}

M
Mark Brown 已提交
409
	wm8994->supplies = kzalloc(sizeof(struct regulator_bulk_data) *
M
Mark Brown 已提交
410
				   wm8994->num_supplies,
M
Mark Brown 已提交
411
				   GFP_KERNEL);
412 413
	if (!wm8994->supplies) {
		ret = -ENOMEM;
M
Mark Brown 已提交
414
		goto err;
415
	}
M
Mark Brown 已提交
416

M
Mark Brown 已提交
417 418 419 420 421 422 423 424 425 426 427 428 429 430 431
	switch (wm8994->type) {
	case WM8994:
		for (i = 0; i < ARRAY_SIZE(wm8994_main_supplies); i++)
			wm8994->supplies[i].supply = wm8994_main_supplies[i];
		break;
	case WM8958:
		for (i = 0; i < ARRAY_SIZE(wm8958_main_supplies); i++)
			wm8994->supplies[i].supply = wm8958_main_supplies[i];
		break;
	default:
		BUG();
		return -EINVAL;
	}
		
	ret = regulator_bulk_get(wm8994->dev, wm8994->num_supplies,
M
Mark Brown 已提交
432 433 434
				 wm8994->supplies);
	if (ret != 0) {
		dev_err(wm8994->dev, "Failed to get supplies: %d\n", ret);
J
Joonyoung Shim 已提交
435
		goto err_supplies;
M
Mark Brown 已提交
436 437
	}

M
Mark Brown 已提交
438
	ret = regulator_bulk_enable(wm8994->num_supplies,
M
Mark Brown 已提交
439 440 441
				    wm8994->supplies);
	if (ret != 0) {
		dev_err(wm8994->dev, "Failed to enable supplies: %d\n", ret);
J
Joonyoung Shim 已提交
442
		goto err_get;
M
Mark Brown 已提交
443 444 445 446 447 448 449
	}

	ret = wm8994_reg_read(wm8994, WM8994_SOFTWARE_RESET);
	if (ret < 0) {
		dev_err(wm8994->dev, "Failed to read ID register\n");
		goto err_enable;
	}
M
Mark Brown 已提交
450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465
	switch (ret) {
	case 0x8994:
		devname = "WM8994";
		if (wm8994->type != WM8994)
			dev_warn(wm8994->dev, "Device registered as type %d\n",
				 wm8994->type);
		wm8994->type = WM8994;
		break;
	case 0x8958:
		devname = "WM8958";
		if (wm8994->type != WM8958)
			dev_warn(wm8994->dev, "Device registered as type %d\n",
				 wm8994->type);
		wm8994->type = WM8958;
		break;
	default:
M
Mark Brown 已提交
466 467 468 469 470 471 472 473 474 475 476 477 478
		dev_err(wm8994->dev, "Device is not a WM8994, ID is %x\n",
			ret);
		ret = -EINVAL;
		goto err_enable;
	}

	ret = wm8994_reg_read(wm8994, WM8994_CHIP_REVISION);
	if (ret < 0) {
		dev_err(wm8994->dev, "Failed to read revision register: %d\n",
			ret);
		goto err_enable;
	}

479 480 481 482 483
	switch (wm8994->type) {
	case WM8994:
		switch (ret) {
		case 0:
		case 1:
M
Mark Brown 已提交
484 485 486
			dev_warn(wm8994->dev,
				 "revision %c not fully supported\n",
				 'A' + ret);
487 488 489 490
			break;
		default:
			break;
		}
M
Mark Brown 已提交
491 492 493 494 495
		break;
	default:
		break;
	}

M
Mark Brown 已提交
496
	dev_info(wm8994->dev, "%s revision %c\n", devname, 'A' + ret);
M
Mark Brown 已提交
497 498

	if (pdata) {
499
		wm8994->irq_base = pdata->irq_base;
M
Mark Brown 已提交
500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526
		wm8994->gpio_base = pdata->gpio_base;

		/* GPIO configuration is only applied if it's non-zero */
		for (i = 0; i < ARRAY_SIZE(pdata->gpio_defaults); i++) {
			if (pdata->gpio_defaults[i]) {
				wm8994_set_bits(wm8994, WM8994_GPIO_1 + i,
						0xffff,
						pdata->gpio_defaults[i]);
			}
		}
	}

	/* In some system designs where the regulators are not in use,
	 * we can achieve a small reduction in leakage currents by
	 * floating LDO outputs.  This bit makes no difference if the
	 * LDOs are enabled, it only affects cases where the LDOs were
	 * in operation and are then disabled.
	 */
	for (i = 0; i < WM8994_NUM_LDO_REGS; i++) {
		if (wm8994_ldo_in_use(pdata, i))
			wm8994_set_bits(wm8994, WM8994_LDO_1 + i,
					WM8994_LDO1_DISCH, WM8994_LDO1_DISCH);
		else
			wm8994_set_bits(wm8994, WM8994_LDO_1 + i,
					WM8994_LDO1_DISCH, 0);
	}

527 528
	wm8994_irq_init(wm8994);

M
Mark Brown 已提交
529 530 531 532 533
	ret = mfd_add_devices(wm8994->dev, -1,
			      wm8994_devs, ARRAY_SIZE(wm8994_devs),
			      NULL, 0);
	if (ret != 0) {
		dev_err(wm8994->dev, "Failed to add children: %d\n", ret);
534
		goto err_irq;
M
Mark Brown 已提交
535 536
	}

537 538 539
	pm_runtime_enable(wm8994->dev);
	pm_runtime_resume(wm8994->dev);

M
Mark Brown 已提交
540 541
	return 0;

542 543
err_irq:
	wm8994_irq_exit(wm8994);
M
Mark Brown 已提交
544
err_enable:
M
Mark Brown 已提交
545
	regulator_bulk_disable(wm8994->num_supplies,
M
Mark Brown 已提交
546 547
			       wm8994->supplies);
err_get:
M
Mark Brown 已提交
548
	regulator_bulk_free(wm8994->num_supplies, wm8994->supplies);
M
Mark Brown 已提交
549 550 551 552 553 554 555 556 557 558
err_supplies:
	kfree(wm8994->supplies);
err:
	mfd_remove_devices(wm8994->dev);
	kfree(wm8994);
	return ret;
}

static void wm8994_device_exit(struct wm8994 *wm8994)
{
559
	pm_runtime_disable(wm8994->dev);
M
Mark Brown 已提交
560
	mfd_remove_devices(wm8994->dev);
561
	wm8994_irq_exit(wm8994);
M
Mark Brown 已提交
562
	regulator_bulk_disable(wm8994->num_supplies,
M
Mark Brown 已提交
563
			       wm8994->supplies);
M
Mark Brown 已提交
564
	regulator_bulk_free(wm8994->num_supplies, wm8994->supplies);
M
Mark Brown 已提交
565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590
	kfree(wm8994->supplies);
	kfree(wm8994);
}

static int wm8994_i2c_read_device(struct wm8994 *wm8994, unsigned short reg,
				  int bytes, void *dest)
{
	struct i2c_client *i2c = wm8994->control_data;
	int ret;
	u16 r = cpu_to_be16(reg);

	ret = i2c_master_send(i2c, (unsigned char *)&r, 2);
	if (ret < 0)
		return ret;
	if (ret != 2)
		return -EIO;

	ret = i2c_master_recv(i2c, dest, bytes);
	if (ret < 0)
		return ret;
	if (ret != bytes)
		return -EIO;
	return 0;
}

static int wm8994_i2c_write_device(struct wm8994 *wm8994, unsigned short reg,
M
Mark Brown 已提交
591
				   int bytes, const void *src)
M
Mark Brown 已提交
592 593
{
	struct i2c_client *i2c = wm8994->control_data;
594
	struct i2c_msg xfer[2];
M
Mark Brown 已提交
595 596 597 598
	int ret;

	reg = cpu_to_be16(reg);

599 600 601 602 603 604 605 606 607 608 609
	xfer[0].addr = i2c->addr;
	xfer[0].flags = 0;
	xfer[0].len = 2;
	xfer[0].buf = (char *)&reg;

	xfer[1].addr = i2c->addr;
	xfer[1].flags = I2C_M_NOSTART;
	xfer[1].len = bytes;
	xfer[1].buf = (char *)src;

	ret = i2c_transfer(i2c->adapter, xfer, 2);
M
Mark Brown 已提交
610 611
	if (ret < 0)
		return ret;
612
	if (ret != 2)
M
Mark Brown 已提交
613 614 615 616 617 618 619 620 621 622 623
		return -EIO;

	return 0;
}

static int wm8994_i2c_probe(struct i2c_client *i2c,
			    const struct i2c_device_id *id)
{
	struct wm8994 *wm8994;

	wm8994 = kzalloc(sizeof(struct wm8994), GFP_KERNEL);
624
	if (wm8994 == NULL)
M
Mark Brown 已提交
625 626 627 628 629 630 631
		return -ENOMEM;

	i2c_set_clientdata(i2c, wm8994);
	wm8994->dev = &i2c->dev;
	wm8994->control_data = i2c;
	wm8994->read_dev = wm8994_i2c_read_device;
	wm8994->write_dev = wm8994_i2c_write_device;
632
	wm8994->irq = i2c->irq;
M
Mark Brown 已提交
633
	wm8994->type = id->driver_data;
M
Mark Brown 已提交
634

M
Mark Brown 已提交
635
	return wm8994_device_init(wm8994, i2c->irq);
M
Mark Brown 已提交
636 637 638 639 640 641 642 643 644 645 646 647
}

static int wm8994_i2c_remove(struct i2c_client *i2c)
{
	struct wm8994 *wm8994 = i2c_get_clientdata(i2c);

	wm8994_device_exit(wm8994);

	return 0;
}

static const struct i2c_device_id wm8994_i2c_id[] = {
M
Mark Brown 已提交
648 649
	{ "wm8994", WM8994 },
	{ "wm8958", WM8958 },
M
Mark Brown 已提交
650 651 652 653
	{ }
};
MODULE_DEVICE_TABLE(i2c, wm8994_i2c_id);

M
Mark Brown 已提交
654 655
static UNIVERSAL_DEV_PM_OPS(wm8994_pm_ops, wm8994_suspend, wm8994_resume,
			    NULL);
656

M
Mark Brown 已提交
657 658
static struct i2c_driver wm8994_i2c_driver = {
	.driver = {
659 660 661
		.name = "wm8994",
		.owner = THIS_MODULE,
		.pm = &wm8994_pm_ops,
M
Mark Brown 已提交
662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688
	},
	.probe = wm8994_i2c_probe,
	.remove = wm8994_i2c_remove,
	.id_table = wm8994_i2c_id,
};

static int __init wm8994_i2c_init(void)
{
	int ret;

	ret = i2c_add_driver(&wm8994_i2c_driver);
	if (ret != 0)
		pr_err("Failed to register wm8994 I2C driver: %d\n", ret);

	return ret;
}
module_init(wm8994_i2c_init);

static void __exit wm8994_i2c_exit(void)
{
	i2c_del_driver(&wm8994_i2c_driver);
}
module_exit(wm8994_i2c_exit);

MODULE_DESCRIPTION("Core support for the WM8994 audio CODEC");
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");