Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1cad1de1 authored by Christian Pellegrin's avatar Christian Pellegrin Committed by Mark Brown
Browse files

ASoC: UDA134x codec driver

parent 6e5d9db2
Loading
Loading
Loading
Loading

include/sound/l3.h

0 → 100644
+18 −0
Original line number Diff line number Diff line
#ifndef _L3_H_
#define _L3_H_ 1

struct l3_pins {
	void (*setdat)(int);
	void (*setclk)(int);
	void (*setmode)(int);
	int data_hold;
	int data_setup;
	int clock_high;
	int mode_hold;
	int mode;
	int mode_setup;
};

int l3_write(struct l3_pins *adap, u8 addr, u8 *data, int len);

#endif
+26 −0
Original line number Diff line number Diff line
/*
 * uda134x.h  --  UDA134x ALSA SoC Codec driver
 *
 * Copyright 2007 Dension Audio Systems Ltd.
 * Author: Zoltan Devai
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */

#ifndef _UDA134X_H
#define _UDA134X_H

#include <sound/l3.h>

struct uda134x_platform_data {
	struct l3_pins l3;
	void (*power) (int);
	int model;
#define UDA134X_UDA1340 1
#define UDA134X_UDA1341 2
#define UDA134X_UDA1344 3
};

#endif /* _UDA134X_H */
+8 −0
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@ config SND_SOC_ALL_CODECS
	select SND_SOC_TLV320AIC26 if SPI_MASTER
	select SND_SOC_TLV320AIC3X if I2C
	select SND_SOC_TWL4030 if TWL4030_CORE
	select SND_SOC_UDA134X
	select SND_SOC_UDA1380 if I2C
	select SND_SOC_WM8510 if (I2C || SPI_MASTER)
	select SND_SOC_WM8580 if I2C
@@ -66,6 +67,9 @@ config SND_SOC_CS4270_VD33_ERRATA
	bool
	depends on SND_SOC_CS4270

config SND_SOC_L3
       tristate

config SND_SOC_SSM2602
	tristate

@@ -85,6 +89,10 @@ config SND_SOC_TWL4030
	tristate
	depends on TWL4030_CORE

config SND_SOC_UDA134X
       tristate
       select SND_SOC_L3

config SND_SOC_UDA1380
        tristate

+4 −0
Original line number Diff line number Diff line
@@ -3,11 +3,13 @@ snd-soc-ad1980-objs := ad1980.o
snd-soc-ad73311-objs := ad73311.o
snd-soc-ak4535-objs := ak4535.o
snd-soc-cs4270-objs := cs4270.o
snd-soc-l3-objs := l3.o
snd-soc-ssm2602-objs := ssm2602.o
snd-soc-tlv320aic23-objs := tlv320aic23.o
snd-soc-tlv320aic26-objs := tlv320aic26.o
snd-soc-tlv320aic3x-objs := tlv320aic3x.o
snd-soc-twl4030-objs := twl4030.o
snd-soc-uda134x-objs := uda134x.o
snd-soc-uda1380-objs := uda1380.o
snd-soc-wm8510-objs := wm8510.o
snd-soc-wm8580-objs := wm8580.o
@@ -27,11 +29,13 @@ obj-$(CONFIG_SND_SOC_AD1980) += snd-soc-ad1980.o
obj-$(CONFIG_SND_SOC_AD73311) += snd-soc-ad73311.o
obj-$(CONFIG_SND_SOC_AK4535)	+= snd-soc-ak4535.o
obj-$(CONFIG_SND_SOC_CS4270)	+= snd-soc-cs4270.o
obj-$(CONFIG_SND_SOC_L3)	+= snd-soc-l3.o
obj-$(CONFIG_SND_SOC_SSM2602)	+= snd-soc-ssm2602.o
obj-$(CONFIG_SND_SOC_TLV320AIC23)	+= snd-soc-tlv320aic23.o
obj-$(CONFIG_SND_SOC_TLV320AIC26)	+= snd-soc-tlv320aic26.o
obj-$(CONFIG_SND_SOC_TLV320AIC3X)	+= snd-soc-tlv320aic3x.o
obj-$(CONFIG_SND_SOC_TWL4030)	+= snd-soc-twl4030.o
obj-$(CONFIG_SND_SOC_UDA134X)	+= snd-soc-uda134x.o
obj-$(CONFIG_SND_SOC_UDA1380)	+= snd-soc-uda1380.o
obj-$(CONFIG_SND_SOC_WM8510)	+= snd-soc-wm8510.o
obj-$(CONFIG_SND_SOC_WM8580)	+= snd-soc-wm8580.o

sound/soc/codecs/l3.c

0 → 100644
+91 −0
Original line number Diff line number Diff line
/*
 * L3 code
 *
 *  Copyright (C) 2008, Christian Pellegrin <chripell@evolware.org>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 *
 * based on:
 *
 * L3 bus algorithm module.
 *
 *  Copyright (C) 2001 Russell King, All Rights Reserved.
 *
 *
 */

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/delay.h>

#include <sound/l3.h>

/*
 * Send one byte of data to the chip.  Data is latched into the chip on
 * the rising edge of the clock.
 */
static void sendbyte(struct l3_pins *adap, unsigned int byte)
{
	int i;

	for (i = 0; i < 8; i++) {
		adap->setclk(0);
		udelay(adap->data_hold);
		adap->setdat(byte & 1);
		udelay(adap->data_setup);
		adap->setclk(1);
		udelay(adap->clock_high);
		byte >>= 1;
	}
}

/*
 * Send a set of bytes to the chip.  We need to pulse the MODE line
 * between each byte, but never at the start nor at the end of the
 * transfer.
 */
static void sendbytes(struct l3_pins *adap, const u8 *buf,
		      int len)
{
	int i;

	for (i = 0; i < len; i++) {
		if (i) {
			udelay(adap->mode_hold);
			adap->setmode(0);
			udelay(adap->mode);
		}
		adap->setmode(1);
		udelay(adap->mode_setup);
		sendbyte(adap, buf[i]);
	}
}

int l3_write(struct l3_pins *adap, u8 addr, u8 *data, int len)
{
	adap->setclk(1);
	adap->setdat(1);
	adap->setmode(1);
	udelay(adap->mode);

	adap->setmode(0);
	udelay(adap->mode_setup);
	sendbyte(adap, addr);
	udelay(adap->mode_hold);

	sendbytes(adap, data, len);

	adap->setclk(1);
	adap->setdat(1);
	adap->setmode(0);

	return len;
}
EXPORT_SYMBOL_GPL(l3_write);

MODULE_DESCRIPTION("L3 bit-banging driver");
MODULE_AUTHOR("Christian Pellegrin <chripell@evolware.org>");
MODULE_LICENSE("GPL");
Loading