由于A33硬件原理图中,LED只有一个LED_EN引脚,所以在 lichee\tools\pack\chips\sun8iw5p1\configs\m86sysconfig.fex中,只需配置LED_EN引脚的GPIO即可,如果把LED配置在audio下,如下
[audio0]
audio_used = 1
;added by Dechao,for contrle microphone
microphone_used = 1
led_shou = port:PG11<1><default><default><0>
则需在lichee/linux-3.4/sound/soc/sunxi/audiocodec/sun8iw5_sndcodec.c中
static int gpio_shou;
static script_item_u item_shou;
static ssize_t shou_store(struct class *class,
struct class_attribute *attr, const char *buf, size_t count) //供应用层write调用copy_from_user
{
if(buf[0] == '1')
{
shou_flag = 1;
gpio_set_value(gpio_shou, 1);
}
else
{
shou_flag = 0;
gpio_set_value(gpio_shou, 0);
}
return count;
}
static ssize_t shou_show(struct class *class,
struct class_attribute *attr, char *buf) //供应用层read调用,相当于copy_to_user(buf, &key_val, 1);
{
return sprintf(buf, "%d\n", shou_flag);
}
static struct class_attribute wire_class_attrs[] = {
__ATTR(shou,0666,shou_show,shou_store), //这里的第一个参数还没搞清楚
__ATTR_NULL
};
static struct class wire_class = {
.name = "wire",
.class_attrs = wire_class_attrs,
};
static int __init sndpcm_codec_probe(struct platform_device *pdev)
{
script_item_value_type_e type;
type = script_get_item("audio0", "led_shou", &item_shou);
if (SCIRPT_ITEM_VALUE_TYPE_PIO != type) {
printk("script_get_item 'led_shou' return type err\n");
return -EFAULT;
}
gpio_shou = item_shou.gpio.gpio;
err = gpio_request(gpio_shou, "led_shou");
if (0 != err) {
printk("request led shou failed!\n");
}
gpio_direction_output(gpio_shou,0);
gpio_set_value(gpio_shou, 1); //给gpio写1,灯常亮
class_register(&wire_class);
}