Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 319699
b: refs/heads/master
c: 52b461b
h: refs/heads/master
i:
  319697: c979222
  319695: ab059aa
v: v3
  • Loading branch information
Mark Brown authored and Samuel Ortiz committed Jul 8, 2012
1 parent deef935 commit 3842996
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 18 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b0ab907d325f99054eb2700a8f8c50776ebfeaf9
refs/heads/master: 52b461b86a9f6c7a86bdcb858e1bbef089fbe6a0
29 changes: 18 additions & 11 deletions trunk/drivers/mfd/wm8350-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@
#include <linux/mfd/wm8350/supply.h>
#include <linux/mfd/wm8350/wdt.h>

#define WM8350_UNLOCK_KEY 0x0013
#define WM8350_LOCK_KEY 0x0000

#define WM8350_CLOCK_CONTROL_1 0x28
#define WM8350_AIF_TEST 0x74

Expand Down Expand Up @@ -295,15 +292,20 @@ EXPORT_SYMBOL_GPL(wm8350_block_write);
*/
int wm8350_reg_lock(struct wm8350 *wm8350)
{
u16 key = WM8350_LOCK_KEY;
int ret;

mutex_lock(&reg_lock_mutex);

ldbg(__func__);
mutex_lock(&io_mutex);
ret = wm8350_write(wm8350, WM8350_SECURITY, 1, &key);

ret = wm8350_reg_write(wm8350, WM8350_SECURITY, WM8350_LOCK_KEY);
if (ret)
dev_err(wm8350->dev, "lock failed\n");
mutex_unlock(&io_mutex);

wm8350->unlocked = false;

mutex_unlock(&reg_lock_mutex);

return ret;
}
EXPORT_SYMBOL_GPL(wm8350_reg_lock);
Expand All @@ -319,15 +321,20 @@ EXPORT_SYMBOL_GPL(wm8350_reg_lock);
*/
int wm8350_reg_unlock(struct wm8350 *wm8350)
{
u16 key = WM8350_UNLOCK_KEY;
int ret;

mutex_lock(&reg_lock_mutex);

ldbg(__func__);
mutex_lock(&io_mutex);
ret = wm8350_write(wm8350, WM8350_SECURITY, 1, &key);

ret = wm8350_reg_write(wm8350, WM8350_SECURITY, WM8350_UNLOCK_KEY);
if (ret)
dev_err(wm8350->dev, "unlock failed\n");
mutex_unlock(&io_mutex);

wm8350->unlocked = true;

mutex_unlock(&reg_lock_mutex);

return ret;
}
EXPORT_SYMBOL_GPL(wm8350_reg_unlock);
Expand Down
5 changes: 0 additions & 5 deletions trunk/drivers/mfd/wm8350-i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@
#include <linux/regmap.h>
#include <linux/slab.h>

static const struct regmap_config wm8350_regmap = {
.reg_bits = 8,
.val_bits = 16,
};

static int wm8350_i2c_probe(struct i2c_client *i2c,
const struct i2c_device_id *id)
{
Expand Down
56 changes: 56 additions & 0 deletions trunk/drivers/mfd/wm8350-regmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -3433,3 +3433,59 @@ const struct wm8350_reg_access wm8350_reg_io_map[] = {
{ 0x0000, 0x0000, 0x0000 }, /* R254 */
{ 0x0000, 0x0000, 0x0000 }, /* R255 */
};

static bool wm8350_readable(struct device *dev, unsigned int reg)
{
return wm8350_reg_io_map[reg].readable;
}

static bool wm8350_writeable(struct device *dev, unsigned int reg)
{
struct wm8350 *wm8350 = dev_get_drvdata(dev);

if (!wm8350->unlocked) {
if ((reg >= WM8350_GPIO_FUNCTION_SELECT_1 &&
reg <= WM8350_GPIO_FUNCTION_SELECT_4) ||
(reg >= WM8350_BATTERY_CHARGER_CONTROL_1 &&
reg <= WM8350_BATTERY_CHARGER_CONTROL_3))
return false;
}

return wm8350_reg_io_map[reg].writable;
}

static bool wm8350_volatile(struct device *dev, unsigned int reg)
{
return wm8350_reg_io_map[reg].vol;
}

static bool wm8350_precious(struct device *dev, unsigned int reg)
{
switch (reg) {
case WM8350_SYSTEM_INTERRUPTS:
case WM8350_INT_STATUS_1:
case WM8350_INT_STATUS_2:
case WM8350_POWER_UP_INT_STATUS:
case WM8350_UNDER_VOLTAGE_INT_STATUS:
case WM8350_OVER_CURRENT_INT_STATUS:
case WM8350_GPIO_INT_STATUS:
case WM8350_COMPARATOR_INT_STATUS:
return true;

default:
return false;
}
}

const struct regmap_config wm8350_regmap = {
.reg_bits = 8,
.val_bits = 16,

.cache_type = REGCACHE_RBTREE,

.max_register = WM8350_MAX_REGISTER,
.readable_reg = wm8350_readable,
.writeable_reg = wm8350_writeable,
.volatile_reg = wm8350_volatile,
.precious_reg = wm8350_precious,
};
7 changes: 6 additions & 1 deletion trunk/include/linux/mfd/wm8350/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <linux/mutex.h>
#include <linux/interrupt.h>
#include <linux/completion.h>
#include <linux/regmap.h>

#include <linux/mfd/wm8350/audio.h>
#include <linux/mfd/wm8350/gpio.h>
Expand Down Expand Up @@ -66,6 +67,9 @@

#define WM8350_MAX_REGISTER 0xFF

#define WM8350_UNLOCK_KEY 0x0013
#define WM8350_LOCK_KEY 0x0000

/*
* Field Definitions.
*/
Expand Down Expand Up @@ -582,6 +586,7 @@

#define WM8350_NUM_IRQ_REGS 7

extern const struct regmap_config wm8350_regmap;
struct wm8350_reg_access {
u16 readable; /* Mask of readable bits */
u16 writable; /* Mask of writable bits */
Expand All @@ -602,7 +607,6 @@ extern const u16 wm8352_mode2_defaults[];
extern const u16 wm8352_mode3_defaults[];

struct wm8350;
struct regmap;

struct wm8350_hwmon {
struct platform_device *pdev;
Expand All @@ -615,6 +619,7 @@ struct wm8350 {
/* device IO */
struct regmap *regmap;
u16 *reg_cache;
bool unlocked;

struct mutex auxadc_mutex;
struct completion auxadc_done;
Expand Down

0 comments on commit 3842996

Please sign in to comment.