6
Copyright (C) 2008 Marc Singer
12
APEX command for sending control messages to the WM8955 codec.
23
#include <linux/string.h>
24
#include <linux/kernel.h>
28
#include <environment.h>
36
#if defined (CONFIG_ENV)
37
static __env struct env_d e_wm8955_i2c_drv = {
38
.key = "wm8955-i2c-drv",
39
.default_value = CONFIG_DRIVER_WM8955_I2C_DRIVER,
40
.description = "I2C driver for wm8955 codec control interface",
44
static inline const char* i2c_driver (void)
46
return lookup_alias_or_env ("wm8955-i2c-drv",
47
CONFIG_DRIVER_WM8955_I2C_DRIVER);
51
static int cmd_wm8955 (int argc, const char** argv)
57
struct descriptor_d d;
63
reg = simple_strtoul (argv[1], NULL, 0);
64
data = simple_strtoul (argv[2], NULL, 0);
66
if ( (result = parse_descriptor (i2c_driver (), &d))
67
|| (result = open_descriptor (&d))) {
68
PRINTF ("%s: unable to open i2c driver '%s'\n", __FUNCTION__, sz);
72
message = ((reg & 0x7f) << 9) | (data & 0x1ff);
73
rgb[0] = (message >> 8) & 0xff;
74
rgb[1] = (message >> 0) & 0xff;
76
printf ("writing [%2d (0x%02x)]<- 0x%03x 0x%x 0x%x\n",
77
reg, reg, data, rgb[0], rgb[1]);
79
result = d.driver->write (&d, rgb, 2);
80
close_descriptor (&d);
82
return (result == 2) ? 0 : result;
86
void wm8955_init (void)
88
/* MCLK pin to WM8955L */
89
IOMUX_PIN_CONFIG_GPIO (MX31_PIN_GPIO3_1);
90
GPIO_PIN_CONFIG_OUTPUT (MX31_PIN_GPIO3_1);
91
GPIO_PIN_SET (MX31_PIN_GPIO3_1);
94
static __service_6 struct service_d wm8955_service = {
96
// .release = wm8955_release,
97
#if !defined (CONFIG_SMALL)
98
// .report = wm8955_report,
103
static __command struct command_d c_wm8955 = {
105
.func = (command_func_t) cmd_wm8955,
106
COMMAND_DESCRIPTION ("send I2C commands to wm8955")
109
" Send DATA to REG of the WM8955L.\n"