[ASoC]fsl_ssi: fix of_property_read_u32_array return value check

2015-02-15 Thread Maciej S. Szmigiero
of_property_read_u32_array returns 0 on success, so the return value shouldn't 
be inverted twice,
first on assignment then in condition expression.

Signed-off-by: Maciej Szmigiero m...@maciej.szmigiero.name

diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index d7365c5..134388f 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -1227,7 +1227,7 @@ static int fsl_ssi_imx_probe(struct platform_device *pdev,
 ssi_private-dma_params_tx.addr = ssi_private-ssi_phys + CCSR_SSI_STX0;
 ssi_private-dma_params_rx.addr = ssi_private-ssi_phys + CCSR_SSI_SRX0;
 
-ret = !of_property_read_u32_array(np, dmas, dmas, 4);
+ret = of_property_read_u32_array(np, dmas, dmas, 4);
 if (ssi_private-use_dma  !ret  dmas[2] == IMX_DMATYPE_SSI_DUAL) {
 ssi_private-use_dual_fifo = true;
 /* When using dual fifo mode, we need to keep watermark

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH]Add VT1613 AC97 codec support

2015-03-06 Thread Maciej S. Szmigiero
Patch to add an VT1613 AC97 codec support.

This codec has additional DC offset removal control,
headphone output and no video input.

Signed-off-by: Maciej Szmigiero m...@maciej.szmigiero.name

diff --git a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c
index 5ee2f17..5bca1a3 100644
--- a/sound/pci/ac97/ac97_codec.c
+++ b/sound/pci/ac97/ac97_codec.c
@@ -177,6 +177,7 @@ static const struct ac97_codec_id snd_ac97_codec_ids[] = {
 { 0x54524123, 0x, TR28602,   NULL,   NULL }, // only 
guess --jk [TR28023 = eMicro EM28023 (new CT1297)]
 { 0x54584e03, 0x, TLV320AIC27,   NULL,   NULL },
 { 0x54584e20, 0x, TLC320AD9xC,   NULL,   NULL },
+{ 0x56494120, 0xfff0, VIA1613,   patch_vt1613,   NULL },
 { 0x56494161, 0x, VIA1612A,  NULL,   NULL }, // 
modified ICE1232 with S/PDIF
 { 0x56494170, 0x, VIA1617A,  patch_vt1617a,  NULL }, // 
modified VT1616 with S/PDIF
 { 0x56494182, 0x, VIA1618,   patch_vt1618,   NULL },
diff --git a/sound/pci/ac97/ac97_patch.c b/sound/pci/ac97/ac97_patch.c
index ceaac1c..eca2210 100644
--- a/sound/pci/ac97/ac97_patch.c
+++ b/sound/pci/ac97/ac97_patch.c
@@ -3352,6 +3352,39 @@ static int patch_cm9780(struct snd_ac97 *ac97)
 }
 
 /*
+ * VIA VT1613 codec
+ */
+static const struct snd_kcontrol_new snd_ac97_controls_vt1613[] = {
+AC97_SINGLE(DC Offset removal, 0x5a, 10, 1, 0),
+};
+
+static int patch_vt1613_specific(struct snd_ac97 *ac97)
+{
+   int err;
+
+   err = patch_build_controls(ac97, snd_ac97_controls_vt1613[0],
+   ARRAY_SIZE(snd_ac97_controls_vt1613));
+   if (err)
+   return err;
+
+   return 0;
+};
+
+static const struct snd_ac97_build_ops patch_vt1613_ops = {
+   .build_specific = patch_vt1613_specific
+};
+
+static int patch_vt1613(struct snd_ac97 *ac97)
+{
+   ac97-build_ops = patch_vt1613_ops;
+
+   ac97-flags |= AC97_HAS_NO_VIDEO;
+   ac97-caps |= AC97_BC_HEADPHONE;
+
+   return 0;
+}
+
+/*
  * VIA VT1616 codec
  */
 static const struct snd_kcontrol_new snd_ac97_controls_vt1616[] = {

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH][ASoC]Add DT bindings for generic ASoC AC97 CODEC driver

2015-03-06 Thread Maciej S. Szmigiero
Add and document DT bindings for generic ASoC AC97 CODEC driver,
make it selectable in config.

Signed-off-by: Maciej Szmigiero m...@maciej.szmigiero.name

diff --git a/Documentation/devicetree/bindings/sound/ac97-generic-codec.txt 
b/Documentation/devicetree/bindings/sound/ac97-generic-codec.txt
new file mode 100644
index 000..ce98698
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/ac97-generic-codec.txt
@@ -0,0 +1,24 @@
+Generic ASoC AC97 CODEC driver
+
+Allows using codecs supported by generic ALSA AC97 code as codecs in ASoC.
+
+Required properties:
+
+  - compatible : linux,ac97-codec
+
+Optional properties:
+
+  - playback-rates : A list of supported playback rates.
+
+  - capture-rates : A list of supported capture rates.
+
+In case one or both of above properties are missing the relevant rate(s) are 
assumed
+to be 8000, 11025, 22050, 44100, 48000.
+
+Example:
+
+ac97codec: ac97-hifi {
+   compatible = linux,ac97-codec;
+   playback-rates = 48000 44100 32000 24000 22050 16000 12000 11025 8000;
+   capture-rates = 48000;
+};
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index 0bddd92..92d6d39 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -16,7 +16,7 @@ config SND_SOC_ALL_CODECS
select SND_SOC_88PM860X if MFD_88PM860X
select SND_SOC_L3
select SND_SOC_AB8500_CODEC if ABX500_CORE
-   select SND_SOC_AC97_CODEC if SND_SOC_AC97_BUS
+   select SND_SOC_AC97_CODEC
select SND_SOC_AD1836 if SPI_MASTER
select SND_SOC_AD193X_SPI if SPI_MASTER
select SND_SOC_AD193X_I2C if I2C
@@ -210,8 +210,9 @@ config SND_SOC_AB8500_CODEC
tristate
 
 config SND_SOC_AC97_CODEC
-   tristate
+   tristate Build generic ASoC AC97 CODEC driver
select SND_AC97_CODEC
+   select SND_SOC_AC97_BUS
 
 config SND_SOC_AD1836
tristate
diff --git a/sound/soc/codecs/ac97.c b/sound/soc/codecs/ac97.c
index d0ac723..25125bf 100644
--- a/sound/soc/codecs/ac97.c
+++ b/sound/soc/codecs/ac97.c
@@ -23,6 +23,12 @@
 #include sound/initval.h
 #include sound/soc.h
 
+struct ac97_private {
+   struct snd_ac97 *ac97;
+   struct snd_pcm_hw_constraint_list playback_rate_constraints;
+   struct snd_pcm_hw_constraint_list capture_rate_constraints;
+};
+
 static const struct snd_soc_dapm_widget ac97_widgets[] = {
SND_SOC_DAPM_INPUT(RX),
SND_SOC_DAPM_OUTPUT(TX),
@@ -33,22 +39,41 @@ static const struct snd_soc_dapm_route ac97_routes[] = {
{ TX, NULL, AC97 Playback },
 };
 
+static const unsigned int default_rates[] = {
+   8000, 11025, 22050, 44100, 48000
+};
+
+static int ac97_startup(struct snd_pcm_substream *substream,
+   struct snd_soc_dai *dai)
+{
+   struct snd_soc_codec *codec = dai-codec;
+   struct ac97_private *ac97 = snd_soc_codec_get_drvdata(codec);
+
+   if (substream-stream == SNDRV_PCM_STREAM_PLAYBACK)
+   snd_pcm_hw_constraint_list(substream-runtime, 0,
+   SNDRV_PCM_HW_PARAM_RATE,
+   ac97-playback_rate_constraints);
+   else
+   snd_pcm_hw_constraint_list(substream-runtime, 0,
+   SNDRV_PCM_HW_PARAM_RATE,
+   ac97-capture_rate_constraints);
+
+   return 0;
+}
+
 static int ac97_prepare(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
 {
struct snd_soc_codec *codec = dai-codec;
-   struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec);
+   struct ac97_private *ac97 = snd_soc_codec_get_drvdata(codec);
 
int reg = (substream-stream == SNDRV_PCM_STREAM_PLAYBACK) ?
  AC97_PCM_FRONT_DAC_RATE : AC97_PCM_LR_ADC_RATE;
-   return snd_ac97_set_rate(ac97, reg, substream-runtime-rate);
+   return snd_ac97_set_rate(ac97-ac97, reg, substream-runtime-rate);
 }
 
-#define STD_AC97_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\
-   SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_44100 |\
-   SNDRV_PCM_RATE_48000)
-
 static const struct snd_soc_dai_ops ac97_dai_ops = {
+   .startup= ac97_startup,
.prepare= ac97_prepare,
 };
 
@@ -58,20 +83,21 @@ static struct snd_soc_dai_driver ac97_dai = {
.stream_name = AC97 Playback,
.channels_min = 1,
.channels_max = 2,
-   .rates = STD_AC97_RATES,
+   .rates = SNDRV_PCM_RATE_KNOT,
.formats = SND_SOC_STD_AC97_FMTS,},
.capture = {
.stream_name = AC97 Capture,
.channels_min = 1,
.channels_max = 2,
-   .rates = STD_AC97_RATES,
+   .rates = SNDRV_PCM_RATE_KNOT,
.formats = SND_SOC_STD_AC97_FMTS,},
.ops = ac97_dai_ops,
 };
 
 static int ac97_soc_probe(struct snd_soc_codec *codec)
 {
-   struct snd_ac97 *ac97;
+   struct ac97_private *ac97 = 

Re: [PATCH][ASoC]Add DT bindings for generic ASoC AC97 CODEC driver

2015-03-07 Thread Maciej S. Szmigiero
W dniu 07.03.2015 15:34, Mark Brown pisze:
 On Sat, Mar 07, 2015 at 02:58:53PM +0100, Maciej S. Szmigiero wrote:
 W dniu 07.03.2015 11:52, Mark Brown pisze:
 On Fri, Mar 06, 2015 at 07:55:26PM +0100, Maciej S. Szmigiero wrote:
 
 AC'97 shouldn't need DT bindings for the CODEC, it's an enumerable bus.
 
 What this driver did / does is essentially to allow attaching AC'97 bus
 to ASoC AC'97 controllers which don't do it on its own (from what I can
 see only board files do it).
 
 That's true, and it's something it's easy to get away with with board
 files, but that doesn't mean it's something we should be doing for
 device tree where we're not just finding an expedient way to load things
 but rather defining an ABI.

Do you recommend then putting AC'97 bus/mixer attach in
simple-card/fsl-asoc-card or controller driver instead?

 This driver originally constrained rates to 8000, 11025, 22050, 44100,
 48000.
 
 An alternative would be to remove this constraint at all from this
 driver and leave such constraining for controller and AC'97 bus code.
 
 That's a much better approach.
 
 But since this driver was originally limited to these rates I think it
 would be safer to do it only when instantiated via OF.
 
 Again, DT is defining an ABI.

Best regards,
Maciej Szmigiero

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH][ASoC]Add DT bindings for generic ASoC AC97 CODEC driver

2015-03-07 Thread Maciej S. Szmigiero
Thanks for looking into the patch.

W dniu 07.03.2015 11:52, Mark Brown pisze:
 On Fri, Mar 06, 2015 at 07:55:26PM +0100, Maciej S. Szmigiero wrote:
 
 Add and document DT bindings for generic ASoC AC97 CODEC driver,
 make it selectable in config.
 
 AC'97 shouldn't need DT bindings for the CODEC, it's an enumerable bus.

What this driver did / does is essentially to allow attaching AC'97 bus
to ASoC AC'97 controllers which don't do it on its own (from what I can
see only board files do it).

 
 +  - playback-rates : A list of supported playback rates.
 +
 +  - capture-rates : A list of supported capture rates.
 
 Why would we need these properties - the sample rate support is defined
 by the standard, and any extensions can be enumerated from the device.

This driver originally constrained rates to 8000, 11025, 22050, 44100,
48000.

An alternative would be to remove this constraint at all from this
driver and leave such constraining for controller and AC'97 bus code.

But since this driver was originally limited to these rates I think it
would be safer to do it only when instantiated via OF.

Best regards,
Maciej Szmigiero

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH][ASoC]Add ability to remove rate constraints from generic ASoC AC'97 CODEC driver

2015-03-10 Thread Maciej S. Szmigiero
Add ability to remove rate constraints from generic ASoC AC'97 CODEC
driver via passed platform data, make it selectable in config.

This way this driver can be used for platforms which don't need
specialized AC'97 CODEC drivers while at the same avoiding
code duplication from implementing equivalent functionality in
a controller driver.

There is no change in behavior when no platform data is passed.

Signed-off-by: Maciej Szmigiero m...@maciej.szmigiero.name

diff --git a/include/sound/soc-ac97.h b/include/sound/soc-ac97.h
new file mode 100644
index 000..ceb4e2f
--- /dev/null
+++ b/include/sound/soc-ac97.h
@@ -0,0 +1,17 @@
+/*
+ * Platform data for generic ASoC AC97 CODEC driver.
+ *
+ * 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.
+ */
+#ifndef __LINUX_SND__SOC_AC97_H
+#define __LINUX_SND__SOC_AC97_H
+
+struct snd_soc_ac97_codec_platform_data {
+   bool playback_rate_constrained;
+   bool capture_rate_constrained;
+};
+
+#endif /* __LINUX_SND__SOC_AC97_H */
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index 0bddd92..92d6d39 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -16,7 +16,7 @@ config SND_SOC_ALL_CODECS
select SND_SOC_88PM860X if MFD_88PM860X
select SND_SOC_L3
select SND_SOC_AB8500_CODEC if ABX500_CORE
-   select SND_SOC_AC97_CODEC if SND_SOC_AC97_BUS
+   select SND_SOC_AC97_CODEC
select SND_SOC_AD1836 if SPI_MASTER
select SND_SOC_AD193X_SPI if SPI_MASTER
select SND_SOC_AD193X_I2C if I2C
@@ -210,8 +210,9 @@ config SND_SOC_AB8500_CODEC
tristate
 
 config SND_SOC_AC97_CODEC
-   tristate
+   tristate Build generic ASoC AC97 CODEC driver
select SND_AC97_CODEC
+   select SND_SOC_AC97_BUS
 
 config SND_SOC_AD1836
tristate
diff --git a/sound/soc/codecs/ac97.c b/sound/soc/codecs/ac97.c
index d0ac723..c3fb845 100644
--- a/sound/soc/codecs/ac97.c
+++ b/sound/soc/codecs/ac97.c
@@ -20,9 +20,16 @@
 #include sound/core.h
 #include sound/pcm.h
 #include sound/ac97_codec.h
+#include sound/soc-ac97.h
 #include sound/initval.h
 #include sound/soc.h
 
+struct ac97_private {
+   struct snd_ac97 *ac97;
+   bool playback_rate_constrained;
+   bool capture_rate_constrained;
+};
+
 static const struct snd_soc_dapm_widget ac97_widgets[] = {
SND_SOC_DAPM_INPUT(RX),
SND_SOC_DAPM_OUTPUT(TX),
@@ -33,22 +40,53 @@ static const struct snd_soc_dapm_route ac97_routes[] = {
{ TX, NULL, AC97 Playback },
 };
 
+static const unsigned int default_rates[] = {
+   8000, 11025, 22050, 44100, 48000
+};
+
+static const struct snd_pcm_hw_constraint_list default_rate_constraints = {
+   .count  = ARRAY_SIZE(default_rates),
+   .list   = default_rates,
+};
+
+static int ac97_startup(struct snd_pcm_substream *substream,
+   struct snd_soc_dai *dai)
+{
+   struct snd_soc_codec *codec = dai-codec;
+   struct ac97_private *ac97 = snd_soc_codec_get_drvdata(codec);
+   bool constrained;
+
+   if (substream-stream == SNDRV_PCM_STREAM_PLAYBACK)
+   constrained = ac97-playback_rate_constrained;
+   else
+   constrained = ac97-capture_rate_constrained;
+
+   if (!constrained)
+   return 0;
+
+   if (substream-stream == SNDRV_PCM_STREAM_PLAYBACK)
+   snd_pcm_hw_constraint_list(substream-runtime, 0,
+   SNDRV_PCM_HW_PARAM_RATE, default_rate_constraints);
+   else
+   snd_pcm_hw_constraint_list(substream-runtime, 0,
+   SNDRV_PCM_HW_PARAM_RATE, default_rate_constraints);
+
+   return 0;
+}
+
 static int ac97_prepare(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
 {
struct snd_soc_codec *codec = dai-codec;
-   struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec);
+   struct ac97_private *ac97 = snd_soc_codec_get_drvdata(codec);
 
int reg = (substream-stream == SNDRV_PCM_STREAM_PLAYBACK) ?
  AC97_PCM_FRONT_DAC_RATE : AC97_PCM_LR_ADC_RATE;
-   return snd_ac97_set_rate(ac97, reg, substream-runtime-rate);
+   return snd_ac97_set_rate(ac97-ac97, reg, substream-runtime-rate);
 }
 
-#define STD_AC97_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\
-   SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_44100 |\
-   SNDRV_PCM_RATE_48000)
-
 static const struct snd_soc_dai_ops ac97_dai_ops = {
+   .startup= ac97_startup,
.prepare= ac97_prepare,
 };
 
@@ -58,20 +96,21 @@ static struct snd_soc_dai_driver ac97_dai = {
.stream_name = AC97 Playback,
.channels_min = 1,
.channels_max = 2,
-   .rates = STD_AC97_RATES,
+ 

Re: [PATCH][ASoC]Add ability to remove rate constraints from generic ASoC AC'97 CODEC driver

2015-03-29 Thread Maciej S. Szmigiero
Thanks for looking into the patch.

W dniu 22.03.2015 19:27, Mark Brown pisze:
 On Wed, Mar 11, 2015 at 12:28:19AM +0100, Maciej S. Szmigiero wrote:
 Add ability to remove rate constraints from generic ASoC AC'97 CODEC
 driver via passed platform data, make it selectable in config.
 
 Please use subject lines matching the style for the subsystem.  This is
 helpful for identifying relevant patches and not getting your messages
 deleted unread...

I assume [PATCH] ASoC: driver: subject format would be right?

 This way this driver can be used for platforms which don't need
 specialized AC'97 CODEC drivers while at the same avoiding
 code duplication from implementing equivalent functionality in
 a controller driver.
 
 I'm sorry but this just doesn't explain what this patch is intended to
 accomplish.  If we can talk to the AC'97 CODEC at all we can already
 identify whatever constraints it has by looking at the ID registers so
 it's not clear when or why a platform would need to use this.  It feels
 like there is some underlying problem that you're trying to address.

This patch itself is supposed to allow using this CODEC driver with
CODECs that support other rates that these that were already hard-coded
in the driver (8000, 11025, 22050, 44100, 48000).

In general sense what I want to accomplish is to add sound support for
UDOO board to the mainline kernel.
It uses i.MX6 SSI core as controller with VT1613 AC'97 codec.

While it would be possible to simply add ac97 bus enumeration to
either fsl_ssi driver or fsl-asoc-card sound card driver it looks to me
that even in this case a platform device for codec would need to be
registered anyway.

This is because as far I see ASoC CODEC DAIs in links are identified
either by OF node or name of their platform device.
I've already tried to accomplish all of this via adding OF node of
AC'97 codec but such patch was rejected.

If the ac97 bus enumeration is added to fsl_ssi driver then there is
also a problem of communicating a name of ac97 platform device
to sound card driver so it can then reference it in DAI links
that it builds.
If such name would be hardcoded then there would be a possibility to
use only one such CODEC in the system
(this SoC theoretically allows up to three).

And, naturally, this would result in a small code duplication with
regard to this generic driver.

Best regards,
Maciej Szmigiero

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH][ASoC]fsl_ssi: fix of_property_read_u32_array return value check

2015-03-04 Thread Maciej S. Szmigiero
of_property_read_u32_array returns 0 on success,
so the return value shouldn't be inverted twice,
first on assignment then in condition expression.

Signed-off-by: Maciej Szmigiero m...@maciej.szmigiero.name

--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -1227,7 +1227,7 @@ static int fsl_ssi_imx_probe(struct platform_device *pdev,
ssi_private-dma_params_tx.addr = ssi_private-ssi_phys + CCSR_SSI_STX0;
ssi_private-dma_params_rx.addr = ssi_private-ssi_phys + CCSR_SSI_SRX0;
 
-   ret = !of_property_read_u32_array(np, dmas, dmas, 4);
+   ret = of_property_read_u32_array(np, dmas, dmas, 4);
if (ssi_private-use_dma  !ret  dmas[2] == IMX_DMATYPE_SSI_DUAL) {
ssi_private-use_dual_fifo = true;
/* When using dual fifo mode, we need to keep watermark

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [ASoC]fsl_ssi: fix of_property_read_u32_array return value check

2015-03-04 Thread Maciej S. Szmigiero
W dniu 24.02.2015 09:24, Mark Brown pisze:
 On Sun, Feb 15, 2015 at 11:11:43PM +0100, Maciej S. Szmigiero wrote:
 of_property_read_u32_array returns 0 on success, so the return value 
 shouldn't be inverted twice,
 first on assignment then in condition expression.
 
 This doesn't apply to current code, please check and resend.  Please
 also keep your changelog under 80 columns as covered in
 SubmittingPatches.
 

Thanks for looking into it,

Against which tree/branch patches for ASoC should be generated?

Best regards,
Maciej Szmigiero

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] ASoC: codecs-ac97: Remove rate constraints

2015-05-09 Thread Maciej S. Szmigiero
Remove rate constraints from generic ASoC AC'97 CODEC.

Supported rates should be detected and constrained anyway by
AC'97 generic code - was tested with VT1613 CODEC and iMX6 SSI
controller.

This way this driver can be used for platforms which don't need
specialized AC'97 CODEC drivers while at the same avoiding
code duplication from implementing equivalent functionality in
a controller driver.

Signed-off-by: Maciej Szmigiero m...@maciej.szmigiero.name

--- a/sound/soc/codecs/ac97.c
+++ b/sound/soc/codecs/ac97.c
@@ -44,10 +44,6 @@ static int ac97_prepare(struct snd_pcm_substream *substream,
return snd_ac97_set_rate(ac97, reg, substream-runtime-rate);
 }
 
-#define STD_AC97_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\
-   SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_44100 |\
-   SNDRV_PCM_RATE_48000)
-
 static const struct snd_soc_dai_ops ac97_dai_ops = {
.prepare= ac97_prepare,
 };
@@ -58,13 +54,13 @@ static struct snd_soc_dai_driver ac97_dai = {
.stream_name = AC97 Playback,
.channels_min = 1,
.channels_max = 2,
-   .rates = STD_AC97_RATES,
+   .rates = SNDRV_PCM_RATE_KNOT,
.formats = SND_SOC_STD_AC97_FMTS,},
.capture = {
.stream_name = AC97 Capture,
.channels_min = 1,
.channels_max = 2,
-   .rates = STD_AC97_RATES,
+   .rates = SNDRV_PCM_RATE_KNOT,
.formats = SND_SOC_STD_AC97_FMTS,},
.ops = ac97_dai_ops,
 };

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [alsa-devel] [PATCH] ASoC: codecs-ac97: Remove rate constraints

2015-05-09 Thread Maciej S. Szmigiero
Hi Fabio,

W dniu 09.05.2015 01:47, Fabio Estevam pisze:
 Hi Maciej,
 
(..)
 
 Please keep me on Cc when you submit further ac97 patches / udoo dts,
 so that I can help testing them.

 Thanks,
 
 Fabio Estevam

Thank you for your kind words,
naturally I will keep you CCed.

Best regards,
Maciej Szmigiero

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] ASoC: codecs-ac97: Remove rate constraints

2015-05-08 Thread Maciej S. Szmigiero
Remove rate constraints from generic ASoC AC'97 CODEC and make
it selectable in config.

Supported rates should be detected and constrained anyway by
AC'97 generic code - was tested with VT1613 CODEC and iMX6 SSI
controller.

This way this driver can be used for platforms which don't need
specialized AC'97 CODEC drivers while at the same avoiding
code duplication from implementing equivalent functionality in
a controller driver.

Resending due to no response received.

Signed-off-by: Maciej Szmigiero m...@maciej.szmigiero.name

diff --git a/sound/soc/codecs/ac97.c b/sound/soc/codecs/ac97.c
index d0ac723..5b3224c 100644
--- a/sound/soc/codecs/ac97.c
+++ b/sound/soc/codecs/ac97.c
@@ -44,10 +44,6 @@ static int ac97_prepare(struct snd_pcm_substream *substream,
return snd_ac97_set_rate(ac97, reg, substream-runtime-rate);
 }
 
-#define STD_AC97_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\
-   SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_44100 |\
-   SNDRV_PCM_RATE_48000)
-
 static const struct snd_soc_dai_ops ac97_dai_ops = {
.prepare= ac97_prepare,
 };
@@ -58,13 +54,13 @@ static struct snd_soc_dai_driver ac97_dai = {
.stream_name = AC97 Playback,
.channels_min = 1,
.channels_max = 2,
-   .rates = STD_AC97_RATES,
+   .rates = SNDRV_PCM_RATE_KNOT,
.formats = SND_SOC_STD_AC97_FMTS,},
.capture = {
.stream_name = AC97 Capture,
.channels_min = 1,
.channels_max = 2,
-   .rates = STD_AC97_RATES,
+   .rates = SNDRV_PCM_RATE_KNOT,
.formats = SND_SOC_STD_AC97_FMTS,},
.ops = ac97_dai_ops,
 };
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index 061c465..84cad9a 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -16,7 +16,7 @@ config SND_SOC_ALL_CODECS
select SND_SOC_88PM860X if MFD_88PM860X
select SND_SOC_L3
select SND_SOC_AB8500_CODEC if ABX500_CORE
-   select SND_SOC_AC97_CODEC if SND_SOC_AC97_BUS
+   select SND_SOC_AC97_CODEC
select SND_SOC_AD1836 if SPI_MASTER
select SND_SOC_AD193X_SPI if SPI_MASTER
select SND_SOC_AD193X_I2C if I2C
@@ -211,8 +211,9 @@ config SND_SOC_AB8500_CODEC
tristate
 
 config SND_SOC_AC97_CODEC
-   tristate
+   tristate Build generic ASoC AC97 CODEC driver
select SND_AC97_CODEC
+   select SND_SOC_AC97_BUS
 
 config SND_SOC_AD1836
tristate

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] ASoC: codecs-ac97: make selectable in config

2015-05-09 Thread Maciej S. Szmigiero
Make generic ASoC AC'97 CODEC selectable in config.

This way this driver can be used for platforms which don't need
specialized AC'97 CODEC drivers but which are not directly
selectable in config themselves (for example DT based ones).

Signed-off-by: Maciej Szmigiero m...@maciej.szmigiero.name

--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -16,7 +16,7 @@ config SND_SOC_ALL_CODECS
select SND_SOC_88PM860X if MFD_88PM860X
select SND_SOC_L3
select SND_SOC_AB8500_CODEC if ABX500_CORE
-   select SND_SOC_AC97_CODEC if SND_SOC_AC97_BUS
+   select SND_SOC_AC97_CODEC
select SND_SOC_AD1836 if SPI_MASTER
select SND_SOC_AD193X_SPI if SPI_MASTER
select SND_SOC_AD193X_I2C if I2C
@@ -212,8 +212,9 @@ config SND_SOC_AB8500_CODEC
tristate
 
 config SND_SOC_AC97_CODEC
-   tristate
+   tristate Build generic ASoC AC97 CODEC driver
select SND_AC97_CODEC
+   select SND_SOC_AC97_BUS
 
 config SND_SOC_AD1836
tristate

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [alsa-devel] [PATCH] ASoC: codecs-ac97: Remove rate constraints

2015-05-08 Thread Maciej S. Szmigiero
W dniu 08.05.2015 23:32, Fabio Estevam pisze:
 On Fri, May 8, 2015 at 6:16 PM, Maciej S. Szmigiero
 m...@maciej.szmigiero.name wrote:
 Remove rate constraints from generic ASoC AC'97 CODEC and make
 it selectable in config.
 
 Shouldn't this be split in two patches?

I've submitted it as one patch because they are two trivial changes
to make the generic ASoC AC'97 CODEC usable for me outside existing
platform files.

But naturally, I can split them and submit them separately
if that would be better.

 Supported rates should be detected and constrained anyway by
 AC'97 generic code - was tested with VT1613 CODEC and iMX6 SSI
 controller.
 
 Nice, I would like to test this on a Udoo board. Care to share the dts
 changes? (I know this is off topic for this list ;-) Apart from the
 dts changes: are there still missing patches in linux-next to make
 audio work in Udoo?

I currently have audio running on this board at kernel based on
vanilla 3.19 and porting required changes part-by-part to linux-next.

Changes required on vanilla 3.19 to have it working are:
* AC'97 audio support needs to be added to fsl-asoc-card,

* AC'97 CODEC platform device needs to be instantiated in fsl_ssi,

* IPG clock needs to be enabled in fsl_ssi AC'97 mode,
so AC'97 regs can be accessed,

* Few small fixes for AC'97 mode in fsl_ssi (missing switch label
for format, missing  fsl_ssi_dai_probe entry in fsl_ssi_ac97_dai,
etc.).

There also is a problem with this CODEC that it seems to pull samples
for S/PDIF output from time to time even if S/PDIF output is disabled.

By default this requests samples in AC'97 slots 10/11 via SLOTREQ,
which in turn causes SSI to enable these slots in SACCST register
and start sending half of the sound samples there.

The end result is that audio suddenly starts to play two times
too fast.

Currently, I have a workaround of setting S/PDIF slot assignment
in CODEC to first front pair so at least it doesn't affect
playback rate.

If you like to have these changes or DT file diff then naturally
I can share them, just they aren't production-quality as of now.

 This way this driver can be used for platforms which don't need
 specialized AC'97 CODEC drivers while at the same avoiding
 code duplication from implementing equivalent functionality in
 a controller driver.

 Resending due to no response received.
 
 No need to put this in the commit log.

 Thanks

Thanks for looking into patch and best regards,
Maciej Szmigiero

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] ASoC: codecs-ac97: make selectable in config

2015-05-13 Thread Maciej S. Szmigiero
Thanks for looking into the patch.

W dniu 12.05.2015 19:58, Mark Brown pisze:
 On Sun, May 10, 2015 at 12:12:04AM +0200, Maciej S. Szmigiero wrote:
 
 @@ -16,7 +16,7 @@ config SND_SOC_ALL_CODECS
  select SND_SOC_88PM860X if MFD_88PM860X
  select SND_SOC_L3
  select SND_SOC_AB8500_CODEC if ABX500_CORE
 -select SND_SOC_AC97_CODEC if SND_SOC_AC97_BUS
 +select SND_SOC_AC97_CODEC
  select SND_SOC_AD1836 if SPI_MASTER
  select SND_SOC_AD193X_SPI if SPI_MASTER
  select SND_SOC_AD193X_I2C if I2C
 
 No, you're missing the point of what _ALL_CODECS does - it builds
 everything possible.  This will break the build for systems without
 AC'97 support.

How?
In the second hunk of the patch I've made SND_SOC_AC97_CODEC select
SND_SOC_AC97_BUS.

ASoC AC'97 CODEC uses only AC'97 symbols defined in
pci/ac97/ac97_codec.c, pci/ac97/ac97_pcm.c and sound/soc/soc-ac97.c.

pci/ac97/ac97_codec.c, pci/ac97/ac97_pcm.c will be built via
SND_SOC_ALL_CODECS - SND_SOC_AC97_CODEC - SND_AC97_CODEC dependency.

sound/soc/soc-ac97.c will be build via SND_SOC_ALL_CODECS -
SND_SOC_AC97_CODEC - SND_SOC_AC97_BUS dependency.

Best regards,
Maciej Szmigiero

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH][ASoC]Add ability to remove rate constraints from generic ASoC AC'97 CODEC driver

2015-04-07 Thread Maciej S. Szmigiero
W dniu 06.04.2015 18:41, Mark Brown pisze:
 On Sun, Apr 05, 2015 at 12:16:40AM +0200, Maciej S. Szmigiero wrote:
 W dniu 30.03.2015 06:19, Mark Brown pisze:
 On Sun, Mar 29, 2015 at 06:00:33PM +0200, Maciej S. Szmigiero wrote:
 
 Alternatively if you're just trying to open up the constraints why not
 just open them up by default and make sure that the AC'97 generic code
 is constraining things appropriately if it's not doing so already?
 
 By 'open them up by default' do you mean removing them altogether 
 from ASOC AC'97 generic CODEC to let the AC'97 bus driver constrain
 rates on its own or do you mean retaining ability to constraint in
 ASOC AC'97 driver, just have it switched off by default?
 
 I mean make the default setting be the maximum possible set of rates and
 then allow the CODEC code to constrain based on what it finds on the
 link.
 
 Please also note that ASoC is spelt ASoC.
 
 (that is, what the current patch did, just change the default setting).
 
 No, it added a device tree property for controlling things.

I meant this patch (about which the Subject line is), which controlled rate
constraints based on passed platform data, not the first one which
added DT support to the generic ASoC AC'97 CODEC driver.

 If the rate constraints are removed (or disabled) from the ASOC AC'97
 generic CODEC driver then it can be used as-is in the (at least) fsl_ssi
 driver by registering AC'97 platform device there using index taken from
 DT property (cell-index) already defined as required in
 Documentation/devicetree/bindings/sound/fsl,ssi.txt.
 
 Now the question is what is more binding: the documentation which
 defines this property as required or DT files which don't define it at all?
 
 The driver really ought to continue to support existing DTs, it can
 complain about them and assume the default value if the property really
 is required for some reason though.

Thanks for explanation.

In this case this property would be only de facto required in DT of board that
I am adding sound to (and in future boards that are also using this
controller - CODEC arrangement), so there won't be any compatibility problems
with existing board DT files.

Best regards,
Maciej Szmigiero

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] ASoC: codecs-ac97: Remove rate constraints

2015-04-10 Thread Maciej S. Szmigiero
Remove rate constraints from generic ASoC AC'97 CODEC and make
it selectable in config.

Supported rates should be detected and constrained anyway by
AC'97 generic code - was tested with VT1613 CODEC and iMX6 SSI
controller.

This way this driver can be used for platforms which don't need
specialized AC'97 CODEC drivers while at the same avoiding
code duplication from implementing equivalent functionality in
a controller driver.

Signed-off-by: Maciej Szmigiero m...@maciej.szmigiero.name

diff --git a/sound/soc/codecs/ac97.c b/sound/soc/codecs/ac97.c
index d0ac723..5b3224c 100644
--- a/sound/soc/codecs/ac97.c
+++ b/sound/soc/codecs/ac97.c
@@ -44,10 +44,6 @@ static int ac97_prepare(struct snd_pcm_substream *substream,
return snd_ac97_set_rate(ac97, reg, substream-runtime-rate);
 }
 
-#define STD_AC97_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\
-   SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_44100 |\
-   SNDRV_PCM_RATE_48000)
-
 static const struct snd_soc_dai_ops ac97_dai_ops = {
.prepare= ac97_prepare,
 };
@@ -58,13 +54,13 @@ static struct snd_soc_dai_driver ac97_dai = {
.stream_name = AC97 Playback,
.channels_min = 1,
.channels_max = 2,
-   .rates = STD_AC97_RATES,
+   .rates = SNDRV_PCM_RATE_KNOT,
.formats = SND_SOC_STD_AC97_FMTS,},
.capture = {
.stream_name = AC97 Capture,
.channels_min = 1,
.channels_max = 2,
-   .rates = STD_AC97_RATES,
+   .rates = SNDRV_PCM_RATE_KNOT,
.formats = SND_SOC_STD_AC97_FMTS,},
.ops = ac97_dai_ops,
 };
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index 061c465..84cad9a 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -16,7 +16,7 @@ config SND_SOC_ALL_CODECS
select SND_SOC_88PM860X if MFD_88PM860X
select SND_SOC_L3
select SND_SOC_AB8500_CODEC if ABX500_CORE
-   select SND_SOC_AC97_CODEC if SND_SOC_AC97_BUS
+   select SND_SOC_AC97_CODEC
select SND_SOC_AD1836 if SPI_MASTER
select SND_SOC_AD193X_SPI if SPI_MASTER
select SND_SOC_AD193X_I2C if I2C
@@ -211,8 +211,9 @@ config SND_SOC_AB8500_CODEC
tristate
 
 config SND_SOC_AC97_CODEC
-   tristate
+   tristate Build generic ASoC AC97 CODEC driver
select SND_AC97_CODEC
+   select SND_SOC_AC97_BUS
 
 config SND_SOC_AD1836
tristate

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH][ASoC]Add ability to remove rate constraints from generic ASoC AC'97 CODEC driver

2015-04-04 Thread Maciej S. Szmigiero
W dniu 30.03.2015 06:19, Mark Brown pisze:
 On Sun, Mar 29, 2015 at 06:00:33PM +0200, Maciej S. Szmigiero wrote:
 W dniu 22.03.2015 19:27, Mark Brown pisze:
 
 Please use subject lines matching the style for the subsystem.  This is
 helpful for identifying relevant patches and not getting your messages
 deleted unread...
 
 I assume [PATCH] ASoC: driver: subject format would be right?
 
 Yes.

Thanks for information.

 I'm sorry but this just doesn't explain what this patch is intended to
 accomplish.  If we can talk to the AC'97 CODEC at all we can already
 identify whatever constraints it has by looking at the ID registers so
 it's not clear when or why a platform would need to use this.  It feels
 like there is some underlying problem that you're trying to address.
 
 This patch itself is supposed to allow using this CODEC driver with
 CODECs that support other rates that these that were already hard-coded
 in the driver (8000, 11025, 22050, 44100, 48000).
 
 You're talking about Linux internal implementation details here but the
 change you are proposing a change to the device tree?  Like I think I
 said in reply to a previous iteration of this patch we can clearly
 enumerate the required information from the hardware already.
 
 While it would be possible to simply add ac97 bus enumeration to
 either fsl_ssi driver or fsl-asoc-card sound card driver it looks to me
 that even in this case a platform device for codec would need to be
 registered anyway.
 
 That's the way the ASoC AC'97 support currently works, yes.
 
 If the ac97 bus enumeration is added to fsl_ssi driver then there is
 also a problem of communicating a name of ac97 platform device
 to sound card driver so it can then reference it in DAI links
 that it builds.
 
 ...
 
 And, naturally, this would result in a small code duplication with
 regard to this generic driver.
 
 This sounds like something that can easily be put in some generic code
 and either used as a helper library by the drivers or just done directly
 from the framework when it knows it's dealing with an AC'97 bus.
 
 Alternatively if you're just trying to open up the constraints why not
 just open them up by default and make sure that the AC'97 generic code
 is constraining things appropriately if it's not doing so already?

By 'open them up by default' do you mean removing them altogether 
from ASOC AC'97 generic CODEC to let the AC'97 bus driver constrain
rates on its own or do you mean retaining ability to constraint in
ASOC AC'97 driver, just have it switched off by default?
(that is, what the current patch did, just change the default setting).

If the rate constraints are removed (or disabled) from the ASOC AC'97
generic CODEC driver then it can be used as-is in the (at least) fsl_ssi
driver by registering AC'97 platform device there using index taken from
DT property (cell-index) already defined as required in
Documentation/devicetree/bindings/sound/fsl,ssi.txt.

This way the AC'97 CODECs can be uniquely identified in case there is more
than one in the system.

Sadly, despite this property being marked as required in documentation no
current DT file seems to define it.

Now the question is what is more binding: the documentation which
defines this property as required or DT files which don't define it at all?

Best regards,
Maciej Szmigiero

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[lm-sensors] [PATCH] hwmon: add driver for Microchip TC74

2015-06-21 Thread Maciej S. Szmigiero
Add hwmon driver for the Microchip TC74.

The TC74 is a single-input 8-bit I2C temperature sensor,
with +-2 degrees centigrade accuracy.

Signed-off-by: Maciej Szmigiero m...@maciej.szmigiero.name

diff --git a/Documentation/hwmon/tc74 b/Documentation/hwmon/tc74
new file mode 100644
index 000..caecb1f
--- /dev/null
+++ b/Documentation/hwmon/tc74
@@ -0,0 +1,20 @@
+Kernel driver tc74
+
+
+Supported chips:
+   * Microchip TC74
+ Prefix: 'tc74'
+ Datasheet: Publicly available at Microchip website.
+
+Description
+---
+
+Driver supports the above part.
+
+The tc74 has an 8-bit sensor, with 1 degree centigrade resolution
+and +- 2 degrees centigrade accuracy.
+
+Notes
+-
+
+Currently entering low power standby mode is not supported.
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index 25d9e72..bbaaa2e 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -1452,6 +1452,16 @@ config SENSORS_INA2XX
  This driver can also be built as a module.  If so, the module
  will be called ina2xx.
 
+config SENSORS_TC74
+   tristate Microchip TC74
+   depends on I2C
+   help
+ If you say yes here you get support for Microchip TC74 single
+ input temperature sensor chips.
+
+ This driver can also be built as a module.  If so, the module
+ will be called tc74.
+
 config SENSORS_THMC50
tristate Texas Instruments THMC50 / Analog Devices ADM1022
depends on I2C
diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile
index b4a40f1..ab90402 100644
--- a/drivers/hwmon/Makefile
+++ b/drivers/hwmon/Makefile
@@ -140,6 +140,7 @@ obj-$(CONFIG_SENSORS_SMSC47B397)+= smsc47b397.o
 obj-$(CONFIG_SENSORS_SMSC47M1) += smsc47m1.o
 obj-$(CONFIG_SENSORS_SMSC47M192)+= smsc47m192.o
 obj-$(CONFIG_SENSORS_AMC6821)  += amc6821.o
+obj-$(CONFIG_SENSORS_TC74) += tc74.o
 obj-$(CONFIG_SENSORS_THMC50)   += thmc50.o
 obj-$(CONFIG_SENSORS_TMP102)   += tmp102.o
 obj-$(CONFIG_SENSORS_TMP103)   += tmp103.o
diff --git a/drivers/hwmon/tc74.c b/drivers/hwmon/tc74.c
new file mode 100644
index 000..5000c58
--- /dev/null
+++ b/drivers/hwmon/tc74.c
@@ -0,0 +1,191 @@
+/*
+ * An hwmon driver for the Microchip TC74
+ *
+ * Copyright 2015 Maciej Szmigiero m...@maciej.szmigiero.name
+ *
+ * Based on ad7414.c:
+ * Copyright 2006 Stefan Roese, DENX Software Engineering
+ * Copyright 2008 Sean MacLennan, PIKA Technologies
+ * Copyright 2008 Frank Edelhaeuser, Spansion Inc.
+ *
+ * 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/module.h
+#include linux/jiffies.h
+#include linux/i2c.h
+#include linux/hwmon.h
+#include linux/hwmon-sysfs.h
+#include linux/err.h
+#include linux/mutex.h
+#include linux/sysfs.h
+#include linux/slab.h
+
+/* TC74 registers */
+#define TC74_REG_TEMP  0x00
+#define TC74_REG_CONFIG0x01
+
+struct tc74_data {
+   struct i2c_client   *client;
+   struct mutexlock;   /* atomic read data updates */
+   charvalid;  /* !=0 if following fields are valid */
+   unsigned long   next_update;/* In jiffies */
+   s8  temp_input; /* Temp value in dC */
+};
+
+static inline s8 tc74_temp_from_reg(s32 reg)
+{
+   u8 v8 = reg  0xff;
+
+   return (s8)v8;
+}
+
+static inline s32 tc74_read(struct i2c_client *client, u8 reg)
+{
+   return i2c_smbus_read_byte_data(client, reg);
+}
+
+static inline s32 tc74_write(struct i2c_client *client, u8 reg, u8 value)
+{
+   return i2c_smbus_write_byte_data(client, reg, value);
+}
+
+static int tc74_update_device(struct device *dev)
+{
+   struct tc74_data *data = dev_get_drvdata(dev);
+   struct i2c_client *client = data-client;
+   int ret;
+
+   ret = mutex_lock_interruptible(data-lock);
+   if (ret)
+   return ret;
+
+   if (time_after(jiffies, data-next_update) || !data-valid) {
+   s32 value;
+
+   value = tc74_read(client, TC74_REG_CONFIG);
+   if (value  0) {
+   dev_dbg(client-dev, TC74_REG_CONFIG read err %d\n,
+   (int)value);
+
+   ret = value;
+   goto ret_unlock;
+   }
+
+   if (!(value  1  6)) {
+   /* not ready yet */
+
+   ret = -EAGAIN;
+   goto ret_unlock;
+   }
+
+   value = tc74_read(client, TC74_REG_TEMP);
+   if (value  0) {
+   dev_dbg(client-dev, TC74_REG_TEMP read err %d\n,
+   (int)value);
+
+   ret = value;
+   goto ret_unlock;
+   

[lm-sensors] [PATCH v2] hwmon: add driver for Microchip TC74

2015-06-21 Thread Maciej S. Szmigiero
Add hwmon driver for the Microchip TC74.

The TC74 is a single-input 8-bit I2C temperature sensor,
with +-2 degrees centigrade accuracy.

Signed-off-by: Maciej Szmigiero m...@maciej.szmigiero.name

diff --git a/Documentation/hwmon/tc74 b/Documentation/hwmon/tc74
new file mode 100644
index 000..43027aa
--- /dev/null
+++ b/Documentation/hwmon/tc74
@@ -0,0 +1,20 @@
+Kernel driver tc74
+
+
+Supported chips:
+   * Microchip TC74
+ Prefix: 'tc74'
+ Datasheet: Publicly available at Microchip website.
+
+Description
+---
+
+Driver supports the above part.
+
+The tc74 has an 8-bit sensor, with 1 degree centigrade resolution
+and +- 2 degrees centigrade accuracy.
+
+Notes
+-
+
+Currently entering low power standby mode is not supported.
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index 25d9e72..bbaaa2e 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -1452,6 +1452,16 @@ config SENSORS_INA2XX
  This driver can also be built as a module.  If so, the module
  will be called ina2xx.
 
+config SENSORS_TC74
+   tristate Microchip TC74
+   depends on I2C
+   help
+ If you say yes here you get support for Microchip TC74 single
+ input temperature sensor chips.
+
+ This driver can also be built as a module.  If so, the module
+ will be called tc74.
+
 config SENSORS_THMC50
tristate Texas Instruments THMC50 / Analog Devices ADM1022
depends on I2C
diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile
index b4a40f1..ab90402 100644
--- a/drivers/hwmon/Makefile
+++ b/drivers/hwmon/Makefile
@@ -140,6 +140,7 @@ obj-$(CONFIG_SENSORS_SMSC47B397)+= smsc47b397.o
 obj-$(CONFIG_SENSORS_SMSC47M1) += smsc47m1.o
 obj-$(CONFIG_SENSORS_SMSC47M192)+= smsc47m192.o
 obj-$(CONFIG_SENSORS_AMC6821)  += amc6821.o
+obj-$(CONFIG_SENSORS_TC74) += tc74.o
 obj-$(CONFIG_SENSORS_THMC50)   += thmc50.o
 obj-$(CONFIG_SENSORS_TMP102)   += tmp102.o
 obj-$(CONFIG_SENSORS_TMP103)   += tmp103.o
diff --git a/drivers/hwmon/tc74.c b/drivers/hwmon/tc74.c
new file mode 100644
index 000..f1fda35
--- /dev/null
+++ b/drivers/hwmon/tc74.c
@@ -0,0 +1,177 @@
+/*
+ * An hwmon driver for the Microchip TC74
+ *
+ * Copyright 2015 Maciej Szmigiero m...@maciej.szmigiero.name
+ *
+ * Based on ad7414.c:
+ * Copyright 2006 Stefan Roese, DENX Software Engineering
+ * Copyright 2008 Sean MacLennan, PIKA Technologies
+ * Copyright 2008 Frank Edelhaeuser, Spansion Inc.
+ *
+ * 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/bitops.h
+#include linux/err.h
+#include linux/hwmon.h
+#include linux/hwmon-sysfs.h
+#include linux/i2c.h
+#include linux/jiffies.h
+#include linux/module.h
+#include linux/mutex.h
+#include linux/slab.h
+#include linux/sysfs.h
+
+/* TC74 registers */
+#define TC74_REG_TEMP  0x00
+#define TC74_REG_CONFIG0x01
+
+struct tc74_data {
+   struct i2c_client   *client;
+   struct mutexlock;   /* atomic read data updates */
+   boolvalid;  /* validity of fields below */
+   unsigned long   next_update;/* In jiffies */
+   s8  temp_input; /* Temp value in dC */
+};
+
+static int tc74_update_device(struct device *dev)
+{
+   struct tc74_data *data = dev_get_drvdata(dev);
+   struct i2c_client *client = data-client;
+   int ret;
+
+   ret = mutex_lock_interruptible(data-lock);
+   if (ret)
+   return ret;
+
+   if (time_after(jiffies, data-next_update) || !data-valid) {
+   s32 value;
+
+   value = i2c_smbus_read_byte_data(client, TC74_REG_CONFIG);
+   if (value  0) {
+   dev_dbg(client-dev, TC74_REG_CONFIG read err %d\n,
+   (int)value);
+
+   ret = value;
+   goto ret_unlock;
+   }
+
+   if (!(value  BIT(6))) {
+   /* not ready yet */
+
+   ret = -EAGAIN;
+   goto ret_unlock;
+   }
+
+   value = i2c_smbus_read_byte_data(client, TC74_REG_TEMP);
+   if (value  0) {
+   dev_dbg(client-dev, TC74_REG_TEMP read err %d\n,
+   (int)value);
+
+   ret = value;
+   goto ret_unlock;
+   }
+
+   data-temp_input = value;
+   data-next_update = jiffies + HZ / 4;
+   data-valid = true;
+   }
+
+ret_unlock:
+   mutex_unlock(data-lock);
+
+   return ret;
+}
+
+static ssize_t show_temp_input(struct device *dev,
+  struct 

Re: [lm-sensors] [PATCH] hwmon: add driver for Microchip TC74

2015-06-21 Thread Maciej S. Szmigiero
Hello Guenter,

Thanks for your review.

Best regards,
Maciej Szmigiero

W dniu 21.06.2015 15:19, Guenter Roeck pisze:
 On 06/21/2015 05:38 AM, Maciej S. Szmigiero wrote:
 Add hwmon driver for the Microchip TC74.

 The TC74 is a single-input 8-bit I2C temperature sensor,
 with +-2 degrees centigrade accuracy.

 Signed-off-by: Maciej Szmigiero m...@maciej.szmigiero.name

 diff --git a/Documentation/hwmon/tc74 b/Documentation/hwmon/tc74
 new file mode 100644
 index 000..caecb1f
 --- /dev/null
 +++ b/Documentation/hwmon/tc74
 @@ -0,0 +1,20 @@
 +Kernel driver tc74
 +
 +
 +Supported chips:
 +   * Microchip TC74
 + Prefix: 'tc74'
 + Datasheet: Publicly available at Microchip website.
 +
 +Description
 +---
 +
 +Driver supports the above part.
 +
 +The tc74 has an 8-bit sensor, with 1 degree centigrade resolution
 +and +- 2 degrees centigrade accuracy.
 +
 +Notes
 +-
 +
 +Currently entering low power standby mode is not supported.
 diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
 index 25d9e72..bbaaa2e 100644
 --- a/drivers/hwmon/Kconfig
 +++ b/drivers/hwmon/Kconfig
 @@ -1452,6 +1452,16 @@ config SENSORS_INA2XX
 This driver can also be built as a module.  If so, the module
 will be called ina2xx.

 +config SENSORS_TC74
 +tristate Microchip TC74
 +depends on I2C
 +help
 +  If you say yes here you get support for Microchip TC74 single
 +  input temperature sensor chips.
 +
 +  This driver can also be built as a module.  If so, the module
 +  will be called tc74.
 +
   config SENSORS_THMC50
   tristate Texas Instruments THMC50 / Analog Devices ADM1022
   depends on I2C
 diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile
 index b4a40f1..ab90402 100644
 --- a/drivers/hwmon/Makefile
 +++ b/drivers/hwmon/Makefile
 @@ -140,6 +140,7 @@ obj-$(CONFIG_SENSORS_SMSC47B397)+= smsc47b397.o
   obj-$(CONFIG_SENSORS_SMSC47M1)+= smsc47m1.o
   obj-$(CONFIG_SENSORS_SMSC47M192)+= smsc47m192.o
   obj-$(CONFIG_SENSORS_AMC6821)+= amc6821.o
 +obj-$(CONFIG_SENSORS_TC74)+= tc74.o
   obj-$(CONFIG_SENSORS_THMC50)+= thmc50.o
   obj-$(CONFIG_SENSORS_TMP102)+= tmp102.o
   obj-$(CONFIG_SENSORS_TMP103)+= tmp103.o
 diff --git a/drivers/hwmon/tc74.c b/drivers/hwmon/tc74.c
 new file mode 100644
 index 000..5000c58
 --- /dev/null
 +++ b/drivers/hwmon/tc74.c
 @@ -0,0 +1,191 @@
 +/*
 + * An hwmon driver for the Microchip TC74
 + *
 + * Copyright 2015 Maciej Szmigiero m...@maciej.szmigiero.name
 + *
 + * Based on ad7414.c:
 + *Copyright 2006 Stefan Roese, DENX Software Engineering
 + *Copyright 2008 Sean MacLennan, PIKA Technologies
 + *Copyright 2008 Frank Edelhaeuser, Spansion Inc.
 + *
 + * 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/module.h
 +#include linux/jiffies.h
 +#include linux/i2c.h
 +#include linux/hwmon.h
 +#include linux/hwmon-sysfs.h
 +#include linux/err.h
 +#include linux/mutex.h
 +#include linux/sysfs.h
 +#include linux/slab.h
 +
 Include files in alphabetic order, please.
 
 +/* TC74 registers */
 +#define TC74_REG_TEMP0x00
 +#define TC74_REG_CONFIG0x01
 +
 +struct tc74_data {
 +struct i2c_client*client;
 +struct mutexlock;/* atomic read data updates */
 +charvalid;/* !=0 if following fields are valid */
 
 bool, please, and use true/false.
 
 +unsigned longnext_update;/* In jiffies */
 +s8temp_input;/* Temp value in dC */
 +};
 +
 +static inline s8 tc74_temp_from_reg(s32 reg)
 +{
 +u8 v8 = reg  0xff;
 +
 +return (s8)v8;
 +}
 +
 +static inline s32 tc74_read(struct i2c_client *client, u8 reg)
 +{
 +return i2c_smbus_read_byte_data(client, reg);
 +}
 +
 +static inline s32 tc74_write(struct i2c_client *client, u8 reg, u8 value)
 +{
 +return i2c_smbus_write_byte_data(client, reg, value);
 +}
 +
 Those three functions are unnecessary; please drop.
 
 +static int tc74_update_device(struct device *dev)
 +{
 +struct tc74_data *data = dev_get_drvdata(dev);
 +struct i2c_client *client = data-client;
 +int ret;
 +
 +ret = mutex_lock_interruptible(data-lock);
 +if (ret)
 +return ret;
 +
 +if (time_after(jiffies, data-next_update) || !data-valid) {
 +s32 value;
 +
 +value = tc74_read(client, TC74_REG_CONFIG);
 +if (value  0) {
 +dev_dbg(client-dev, TC74_REG_CONFIG read err %d\n,
 +(int)value);
 +
 +ret = value;
 +goto ret_unlock;
 +}
 +
 +if (!(value  1  6)) {
 
 Please use BIT().
 
 +/* not ready yet */
 +
 +ret = -EAGAIN;
 +goto ret_unlock;
 +}
 +
 +value = tc74_read(client

[PATCH] usb: ci_hdrc_imx: add optional hub clock

2015-06-21 Thread Maciej S. Szmigiero
This patch adds ability to define optional clock of connected
USB hub to ChipIdea i.MX usb controller driver.

This is needed for example for UDOO board.
Previously, this board DT file used a fact that non-core registers
of this USB controller have a separate driver (usbmisc_imx) which
did allow defining a separate clock.

Because the non-core registers are in fact using the same clock as
main controller this allowed to use one of such clock definitions
to enable USB hub clock instead.

However, since commit 73dea4a912b2
(usb: chipidea: usbmisc_imx: delete clock information) this
possibility no longer exists and loading USB support on this board
results in a hard SoC lockup.

Note that this is not specific to particular USB hub chip used,
rather than to a particular board.
Since this is a DT-based board there is no board platform file to
put such clock enable.
Also, USB bus devices aren't instantiated in DT file since it is an
enumerable bus.

NOP PHY also can't be used as clock consumer since this
USB controller needs a true MXS phy definition, which accepts only
one clock (different from USB controller one).

Based on a patch previously submitted by Fabio Estevam, with consent.

Signed-off-by: Maciej Szmigiero m...@maciej.szmigiero.name

diff --git a/Documentation/devicetree/bindings/usb/ci-hdrc-imx.txt 
b/Documentation/devicetree/bindings/usb/ci-hdrc-imx.txt
index 38a5480..fc65f1c 100644
--- a/Documentation/devicetree/bindings/usb/ci-hdrc-imx.txt
+++ b/Documentation/devicetree/bindings/usb/ci-hdrc-imx.txt
@@ -5,6 +5,8 @@ Required properties:
 - reg: Should contain registers location and length
 - interrupts: Should contain controller interrupt
 - fsl,usbphy: phandle of usb phy that connects to the port
+- clocks: phandles of clocks that drive the controller and optionally
+  an USB hub connected to it
 
 Recommended properies:
 - phy_type: the type of the phy connected to the core. Should be one
@@ -20,12 +22,14 @@ Optional properties:
 - external-vbus-divider: enables off-chip resistor divider for Vbus
 - maximum-speed: limit the maximum connection speed to full-speed.
 - tpl-support: TPL (Targeted Peripheral List) feature for targeted hosts
+- clock-names: must be default, hub if optional USB hub clock is used
 
 Examples:
 usb@02184000 { /* USB OTG */
compatible = fsl,imx6q-usb, fsl,imx27-usb;
reg = 0x02184000 0x200;
interrupts = 0 43 0x04;
+   clocks = clks IMX6QDL_CLK_USBOH3;
fsl,usbphy = usbphy1;
fsl,usbmisc = usbmisc 0;
disable-over-current;
diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c 
b/drivers/usb/chipidea/ci_hdrc_imx.c
index 389f0e0..bb7f859 100644
--- a/drivers/usb/chipidea/ci_hdrc_imx.c
+++ b/drivers/usb/chipidea/ci_hdrc_imx.c
@@ -65,6 +65,7 @@ struct ci_hdrc_imx_data {
struct usb_phy *phy;
struct platform_device *ci_pdev;
struct clk *clk;
+   struct clk *clk_hub;
struct imx_usbmisc_data *usbmisc_data;
bool supports_runtime_pm;
bool in_lpm;
@@ -196,6 +197,16 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
goto disable_device;
}
 
+   data-clk_hub = devm_clk_get(pdev-dev, hub);
+   if (!IS_ERR(data-clk_hub)) {
+   ret = clk_prepare_enable(data-clk_hub);
+   if (ret) {
+   dev_err(pdev-dev,
+   Failed to enable clk_hub: %d\n, ret);
+   goto disable_device;
+   }
+   }
+
platform_set_drvdata(pdev, data);
 
if (data-supports_runtime_pm) {
@@ -223,6 +234,8 @@ static int ci_hdrc_imx_remove(struct platform_device *pdev)
pm_runtime_disable(pdev-dev);
pm_runtime_put_noidle(pdev-dev);
}
+   if (!IS_ERR(data-clk_hub))
+   clk_disable_unprepare(data-clk_hub);
ci_hdrc_remove_device(data-ci_pdev);
clk_disable_unprepare(data-clk);
 

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] usb: ci_hdrc_imx: add optional hub clock

2015-06-24 Thread Maciej S. Szmigiero
Hi Peter,

W dniu 23.06.2015 04:55, Peter Chen pisze:
 On Mon, Jun 22, 2015 at 12:54:14AM +0800, Maciej S. Szmigiero wrote:
 This patch adds ability to define optional clock of connected
 USB hub to ChipIdea i.MX usb controller driver.

 This is needed for example for UDOO board.
 Previously, this board DT file used a fact that non-core registers
 of this USB controller have a separate driver (usbmisc_imx) which
 did allow defining a separate clock.

 Because the non-core registers are in fact using the same clock as
 main controller this allowed to use one of such clock definitions
 to enable USB hub clock instead.

 However, since commit 73dea4a912b2
 (usb: chipidea: usbmisc_imx: delete clock information) this
 possibility no longer exists and loading USB support on this board
 results in a hard SoC lockup.

 Note that this is not specific to particular USB hub chip used,
 rather than to a particular board.
 Since this is a DT-based board there is no board platform file to
 put such clock enable.
 Also, USB bus devices aren't instantiated in DT file since it is an
 enumerable bus.

 NOP PHY also can't be used as clock consumer since this
 USB controller needs a true MXS phy definition, which accepts only
 one clock (different from USB controller one).

 Based on a patch previously submitted by Fabio Estevam, with consent.

 Signed-off-by: Maciej Szmigiero m...@maciej.szmigiero.name

(..)
 Hi Maciej,
 
 As I said before, the USB HUB is just an USB peripheral, we should
 not put a peripheral's clock information to controller driver, I think
 hub driver should take responsibilities for it, just like other usb
 pheripheral drivers, like usb modem, etc. You can talk it with Alan
 Stern about it.

I understand you position, but there is a problem with this solution
that USB devices - including hubs - as devices on an enumerable bus
don't have DT bindings to put such clock handle in,
since they are instantiated by their bus scanning code. 

If such devices would be added to DT at least there would be need to
somehow match the discovered device with its DT counterpart.
In case of USB this would need address like controller X,
port x (or port x,y,z in case of multiple hubs in between controller
and device).

As far I see there is nothing like this in USB core yet.

Of course, there is still possibly to add something like a generic
OF USB hub driver which will take care of configuring extra clocks,
pins, GPIOs, etc. but which will be otherwise unrelated to normal
USB hub driver.

Best regards,
Maciej Szmigiero

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] ASoC: codecs: use SNDRV_PCM_FMTBIT_* for format bitmask

2015-05-27 Thread Maciej S. Szmigiero
W dniu 26.05.2015 16:09, Takashi Iwai pisze:
 At Tue, 26 May 2015 16:03:17 +0200,
 Maciej S. Szmigiero wrote:

 Hello Takashi,

 W dniu 26.05.2015 07:29, Takashi Iwai pisze:
 At Sat, 23 May 2015 18:32:29 +0200,
 Maciej S. Szmigiero wrote:

 snd_soc_pcm_stream.formats is a bitmask of SNDRV_PCM_FMTBIT_*,
 not of SNDRV_PCM_FORMAT_* (which are sequential integers),
 however some of ASoC CODEC drivers use these values instead.

 Found out by sparse on 0-day kernel tester.

 Signed-off-by: Maciej Szmigiero m...@maciej.szmigiero.name

 Wow, that made me wonder how these drivers could actually work.

 Maybe, by coincidence, the wrong defines contained enough bits
 set to actually select some common, working format with their
 controllers?
 
 Well, FORMAT_S16_LE = 2, and FORMAT_S18_3LE = 40.  So bits 1, 3 and 5
 are set, which corresponds to U8, S16_BE and U16_BE.  Hmm.
 
 BTW, how did you detect it?  Any static analyzer like sparse or
 smatch?  sparse didn't detect it at the last time I tried, IIRC...

 I've received an e-mail from kbuild test robot at
 0-DAY kernel test infrastructure that automated testing there
 using sparse found this issue on wm9713 and stac9766 CODECs.

 The exact warning was:
 sound/soc/codecs/stac9766.c:324:28: sparse: incorrect type in initializer 
 (different base types)
sound/soc/codecs/stac9766.c:324:28:expected unsigned long long 
 [unsigned] [usertype] formats
sound/soc/codecs/stac9766.c:324:28:got restricted snd_pcm_format_t 
 [usertype] noident

 What is important the warning doesn't show unless a check build
 is made with CF=-D__CHECK_ENDIAN__ .
 
 Ah, thanks, that was the missing piece.
 
 Upon checking I've found the same issue also in two other CODECs,
 which aren't normally being built on x86_64 (target architecture
 for above automated build) even when SND_SOC_ALL_CODECS is selected.
 
 Oh it'd be great if you submit fixes :)

The fixes for these two remaining CODECs were included in the patch
(I've meant that these two weren't in the automated checking report
I've received).

Upon looking again at it the 0-DAY kernel test infrastructure
have to be using some limited config, since all of the CODECs
with this issue are being built/checked in allyesconfig
(it selects the required dependences for them even on x86_64).

 thanks,
 
 Takashi
 

Thanks,
Maciej Szmigiero

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] ASoC: fsl_ssi: fix AC'97 mode

2015-06-27 Thread Maciej S. Szmigiero
Currently the AC'97 mode in fsl_ssi driver isn't functional.

This patch implements the following changes to make it work
properly:
* IPG clock have to be enabled during AC'97 CODEC
register access,
* AC'97 DAI driver struct need the same probe method as
I2S one to setup DMA params,
* AC'97 bus can support asymmetric playback/capture rates,
* Check whether setting AC'97 ops succeeded and
clean them on removal so the driver can be reloaded,
* AC'97 CODEC will be instantiated in AC'97 mode,
* Set DAI format function small fixes in AC'97 mode.

Tested on UDOO board.

Signed-off-by: Maciej Szmigiero m...@maciej.szmigiero.name

diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index c7647e0..9a63df2 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -900,14 +900,16 @@ static int _fsl_ssi_set_dai_fmt(struct device *dev,
scr = ~CCSR_SSI_SCR_SYS_CLK_EN;
break;
default:
-   return -EINVAL;
+   if (!fsl_ssi_is_ac97(ssi_private))
+   return -EINVAL;
}
 
stcr |= strcr;
srcr |= strcr;
 
-   if (ssi_private-cpu_dai_drv.symmetric_rates) {
-   /* Need to clear RXDIR when using SYNC mode */
+   if (ssi_private-cpu_dai_drv.symmetric_rates
+   || fsl_ssi_is_ac97(ssi_private)) {
+   /* Need to clear RXDIR when using SYNC or AC97 mode */
srcr = ~CCSR_SSI_SRCR_RXDIR;
scr |= CCSR_SSI_SCR_SYN;
}
@@ -1101,6 +1103,7 @@ static const struct snd_soc_component_driver 
fsl_ssi_component = {
 
 static struct snd_soc_dai_driver fsl_ssi_ac97_dai = {
.bus_control = true,
+   .probe = fsl_ssi_dai_probe,
.playback = {
.stream_name = AC97 Playback,
.channels_min = 2,
@@ -1127,10 +1130,17 @@ static void fsl_ssi_ac97_write(struct snd_ac97 *ac97, 
unsigned short reg,
struct regmap *regs = fsl_ac97_data-regs;
unsigned int lreg;
unsigned int lval;
+   int ret;
 
if (reg  0x7f)
return;
 
+   ret = clk_prepare_enable(fsl_ac97_data-clk);
+   if (ret) {
+   pr_err(ac97 write clk_prepare_enable failed: %d\n,
+   ret);
+   return;
+   }
 
lreg = reg   12;
regmap_write(regs, CCSR_SSI_SACADD, lreg);
@@ -1141,6 +1151,8 @@ static void fsl_ssi_ac97_write(struct snd_ac97 *ac97, 
unsigned short reg,
regmap_update_bits(regs, CCSR_SSI_SACNT, CCSR_SSI_SACNT_RDWR_MASK,
CCSR_SSI_SACNT_WR);
udelay(100);
+
+   clk_disable_unprepare(fsl_ac97_data-clk);
 }
 
 static unsigned short fsl_ssi_ac97_read(struct snd_ac97 *ac97,
@@ -1151,6 +1163,14 @@ static unsigned short fsl_ssi_ac97_read(struct snd_ac97 
*ac97,
unsigned short val = -1;
u32 reg_val;
unsigned int lreg;
+   int ret;
+
+   ret = clk_prepare_enable(fsl_ac97_data-clk);
+   if (ret) {
+   pr_err(ac97 read clk_prepare_enable failed: %d\n,
+   ret);
+   return -1;
+   }
 
lreg = (reg  0x7f)   12;
regmap_write(regs, CCSR_SSI_SACADD, lreg);
@@ -1162,6 +1182,8 @@ static unsigned short fsl_ssi_ac97_read(struct snd_ac97 
*ac97,
regmap_read(regs, CCSR_SSI_SACDAT, reg_val);
val = (reg_val  4)  0x;
 
+   clk_disable_unprepare(fsl_ac97_data-clk);
+
return val;
 }
 
@@ -1291,6 +1313,7 @@ static int fsl_ssi_probe(struct platform_device *pdev)
struct resource *res;
void __iomem *iomem;
char name[64];
+   bool newbinding;
 
of_id = of_match_device(fsl_ssi_ids, pdev-dev);
if (!of_id || !of_id-data)
@@ -1320,7 +1343,11 @@ static int fsl_ssi_probe(struct platform_device *pdev)
 
fsl_ac97_data = ssi_private;
 
-   snd_soc_set_ac97_ops_of_reset(fsl_ssi_ac97_ops, pdev);
+   ret = snd_soc_set_ac97_ops_of_reset(fsl_ssi_ac97_ops, pdev);
+   if (ret) {
+   dev_err(pdev-dev, could not set AC'97 ops\n);
+   return ret;
+   }
} else {
/* Initialize this copy of the CPU DAI driver structure */
memcpy(ssi_private-cpu_dai_drv, fsl_ssi_dai_template,
@@ -1357,7 +1384,9 @@ static int fsl_ssi_probe(struct platform_device *pdev)
 
/* Are the RX and the TX clocks locked? */
if (!of_find_property(np, fsl,ssi-asynchronous, NULL)) {
-   ssi_private-cpu_dai_drv.symmetric_rates = 1;
+   if (!fsl_ssi_is_ac97(ssi_private))
+   ssi_private-cpu_dai_drv.symmetric_rates = 1;
+
ssi_private-cpu_dai_drv.symmetric_channels = 1;
ssi_private-cpu_dai_drv.symmetric_samplebits = 1;
}
@@ -1405,7 +1434,8 @@ static int fsl_ssi_probe(struct platform_device *pdev)
 * that the machine driver uses new binding which does 

Re: [PATCH] ASoC: fsl_ssi: fix AC'97 mode

2015-06-27 Thread Maciej S. Szmigiero
Hello Fabio,

W dniu 28.06.2015 01:06, Fabio Estevam pisze:
 Hi Maciej,
 
 On Sat, Jun 27, 2015 at 7:51 PM, Maciej S. Szmigiero
 m...@maciej.szmigiero.name wrote:
 Currently the AC'97 mode in fsl_ssi driver isn't functional.
 
 Thanks for the fix. I look forward to test it on my udoo board.

Thanks.

 This patch implements the following changes to make it work
 properly:
 * IPG clock have to be enabled during AC'97 CODEC
 register access,
 * AC'97 DAI driver struct need the same probe method as
 I2S one to setup DMA params,
 * AC'97 bus can support asymmetric playback/capture rates,
 * Check whether setting AC'97 ops succeeded and
 clean them on removal so the driver can be reloaded,
 * AC'97 CODEC will be instantiated in AC'97 mode,
 * Set DAI format function small fixes in AC'97 mode.
 
 It seems like a lot of changes in a single patch.
 
 Care to split it into smaller pieces?

OK, I will resend this split into individual patches.

 +
 +   ret = clk_prepare_enable(fsl_ac97_data-clk);
 +   if (ret) {
 +   pr_err(ac97 read clk_prepare_enable failed: %d\n,
 +   ret);
 +   return -1;

 'return ret' would be better here.

This function normal return value is an AC'97 register value,
so isn't more appropriate to return 0x in case of error
than linux error code?

 Thanks

Best regards,
Maciej Szmigiero

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] ASoC: fsl_ssi: fix AC'97 mode

2015-06-28 Thread Maciej S. Szmigiero
W dniu 28.06.2015 06:27, Timur Tabi pisze:
 Maciej S. Szmigiero wrote:
 +if (newbinding  fsl_ssi_is_ac97(ssi_private)) {
 
 Is the newbinding necessary?  I thought only the original PowerPC device 
 trees were the only one that have the old binding, and they never supported 
 AC97.

If there isn't going to be new platforms added with old bindings then this 
won't be needed - I'll remove it.

Best regards,
Maciej Szmigiero

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/6] ASoC: fsl_ssi: enable IPG clock during AC'97 reg access

2015-06-28 Thread Maciej S. Szmigiero
IPG clock have to be enabled during AC'97 CODEC register
access in fsl_ssi driver.

Signed-off-by: Maciej Szmigiero m...@maciej.szmigiero.name
---
 sound/soc/fsl/fsl_ssi.c |   19 +++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index c7647e0..9c46c7d 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -1127,10 +1127,17 @@ static void fsl_ssi_ac97_write(struct snd_ac97 *ac97, 
unsigned short reg,
struct regmap *regs = fsl_ac97_data-regs;
unsigned int lreg;
unsigned int lval;
+   int ret;
 
if (reg  0x7f)
return;
 
+   ret = clk_prepare_enable(fsl_ac97_data-clk);
+   if (ret) {
+   pr_err(ac97 write clk_prepare_enable failed: %d\n,
+   ret);
+   return;
+   }
 
lreg = reg   12;
regmap_write(regs, CCSR_SSI_SACADD, lreg);
@@ -1141,6 +1148,8 @@ static void fsl_ssi_ac97_write(struct snd_ac97 *ac97, 
unsigned short reg,
regmap_update_bits(regs, CCSR_SSI_SACNT, CCSR_SSI_SACNT_RDWR_MASK,
CCSR_SSI_SACNT_WR);
udelay(100);
+
+   clk_disable_unprepare(fsl_ac97_data-clk);
 }
 
 static unsigned short fsl_ssi_ac97_read(struct snd_ac97 *ac97,
@@ -1151,6 +1160,14 @@ static unsigned short fsl_ssi_ac97_read(struct snd_ac97 
*ac97,
unsigned short val = -1;
u32 reg_val;
unsigned int lreg;
+   int ret;
+
+   ret = clk_prepare_enable(fsl_ac97_data-clk);
+   if (ret) {
+   pr_err(ac97 read clk_prepare_enable failed: %d\n,
+   ret);
+   return -1;
+   }
 
lreg = (reg  0x7f)   12;
regmap_write(regs, CCSR_SSI_SACADD, lreg);
@@ -1162,6 +1179,8 @@ static unsigned short fsl_ssi_ac97_read(struct snd_ac97 
*ac97,
regmap_read(regs, CCSR_SSI_SACDAT, reg_val);
val = (reg_val  4)  0x;
 
+   clk_disable_unprepare(fsl_ac97_data-clk);
+
return val;
 }
 

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/6] ASoC: fsl_ssi: AC'97 DAI driver needs probe method too

2015-06-28 Thread Maciej S. Szmigiero
AC'97 DAI driver struct need the same probe method as
I2S one to setup DMA params in fsl_ssi driver.

Signed-off-by: Maciej Szmigiero m...@maciej.szmigiero.name
---
 sound/soc/fsl/fsl_ssi.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index 9c46c7d..2ce9e1d 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -1101,6 +1101,7 @@ static const struct snd_soc_component_driver 
fsl_ssi_component = {
 
 static struct snd_soc_dai_driver fsl_ssi_ac97_dai = {
.bus_control = true,
+   .probe = fsl_ssi_dai_probe,
.playback = {
.stream_name = AC97 Playback,
.channels_min = 2,

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/6] ASoC: fsl_ssi: enable AC'97 asymmetric rates

2015-06-28 Thread Maciej S. Szmigiero
AC'97 bus can support asymmetric playback/capture rates
so enable them in this case in fsl_ssi driver.

Signed-off-by: Maciej Szmigiero m...@maciej.szmigiero.name
---
 sound/soc/fsl/fsl_ssi.c |4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index 2ce9e1d..f3034b9 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -1377,7 +1377,9 @@ static int fsl_ssi_probe(struct platform_device *pdev)
 
/* Are the RX and the TX clocks locked? */
if (!of_find_property(np, fsl,ssi-asynchronous, NULL)) {
-   ssi_private-cpu_dai_drv.symmetric_rates = 1;
+   if (!fsl_ssi_is_ac97(ssi_private))
+   ssi_private-cpu_dai_drv.symmetric_rates = 1;
+
ssi_private-cpu_dai_drv.symmetric_channels = 1;
ssi_private-cpu_dai_drv.symmetric_samplebits = 1;
}

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 6/6] ASoC: fsl_ssi: adjust set DAI format in AC'97 mode

2015-06-28 Thread Maciej S. Szmigiero
Adjust set DAI format function in fsl_ssi driver so it
doesn't fail and clears RXDIR in AC'97 mode.

Signed-off-by: Maciej Szmigiero m...@maciej.szmigiero.name
---
 sound/soc/fsl/fsl_ssi.c |8 +---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index e79dc16..d043c7c 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -900,14 +900,16 @@ static int _fsl_ssi_set_dai_fmt(struct device *dev,
scr = ~CCSR_SSI_SCR_SYS_CLK_EN;
break;
default:
-   return -EINVAL;
+   if (!fsl_ssi_is_ac97(ssi_private))
+   return -EINVAL;
}
 
stcr |= strcr;
srcr |= strcr;
 
-   if (ssi_private-cpu_dai_drv.symmetric_rates) {
-   /* Need to clear RXDIR when using SYNC mode */
+   if (ssi_private-cpu_dai_drv.symmetric_rates
+   || fsl_ssi_is_ac97(ssi_private)) {
+   /* Need to clear RXDIR when using SYNC or AC97 mode */
srcr = ~CCSR_SSI_SRCR_RXDIR;
scr |= CCSR_SSI_SCR_SYN;
}

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 4/6] ASoC: fsl_ssi: add AC'97 ops setting check and cleanup

2015-06-28 Thread Maciej S. Szmigiero
Check whether setting AC'97 ops succeeded and clean them
on removal so the fsl_ssi driver can be reloaded.

Signed-off-by: Maciej Szmigiero m...@maciej.szmigiero.name
---
 sound/soc/fsl/fsl_ssi.c |9 -
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index f3034b9..0b4fcd9 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -1340,7 +1340,11 @@ static int fsl_ssi_probe(struct platform_device *pdev)
 
fsl_ac97_data = ssi_private;
 
-   snd_soc_set_ac97_ops_of_reset(fsl_ssi_ac97_ops, pdev);
+   ret = snd_soc_set_ac97_ops_of_reset(fsl_ssi_ac97_ops, pdev);
+   if (ret) {
+   dev_err(pdev-dev, could not set AC'97 ops\n);
+   return ret;
+   }
} else {
/* Initialize this copy of the CPU DAI driver structure */
memcpy(ssi_private-cpu_dai_drv, fsl_ssi_dai_template,
@@ -1480,6 +1484,9 @@ static int fsl_ssi_remove(struct platform_device *pdev)
if (ssi_private-soc-imx)
fsl_ssi_imx_clean(pdev, ssi_private);
 
+   if (fsl_ssi_is_ac97(ssi_private))
+   snd_soc_set_ac97_ops(NULL);
+
return 0;
 }
 

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 5/6] ASoC: fsl_ssi: instantiate AC'97 CODEC

2015-06-28 Thread Maciej S. Szmigiero
Instantiate AC'97 CODEC in fsl_ssi driver AC'97 mode.

Signed-off-by: Maciej Szmigiero m...@maciej.szmigiero.name
---
 sound/soc/fsl/fsl_ssi.c |   21 +
 1 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index 0b4fcd9..e79dc16 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -1460,6 +1460,27 @@ done:
_fsl_ssi_set_dai_fmt(pdev-dev, ssi_private,
 ssi_private-dai_fmt);
 
+   if (fsl_ssi_is_ac97(ssi_private)) {
+   u32 ssi_idx;
+
+   ret = of_property_read_u32(np, cell-index, ssi_idx);
+   if (ret) {
+   dev_err(pdev-dev, cannot get SSI index property\n);
+   goto error_sound_card;
+   }
+
+   ssi_private-pdev =
+   platform_device_register_data(NULL,
+   ac97-codec, ssi_idx, NULL, 0);
+   if (IS_ERR(ssi_private-pdev)) {
+   ret = PTR_ERR(ssi_private-pdev);
+   dev_err(pdev-dev,
+   failed to register AC97 codec platform: %d\n,
+   ret);
+   goto error_sound_card;
+   }
+   }
+
return 0;
 
 error_sound_card:

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 3/6] ASoC: fsl_ssi: enable AC'97 asymmetric rates

2015-06-28 Thread Maciej S. Szmigiero
W dniu 28.06.2015 16:01, Timur Tabi pisze:
 Maciej S. Szmigiero wrote:
   /* Are the RX and the TX clocks locked? */
   if (!of_find_property(np, fsl,ssi-asynchronous, NULL)) {
 -ssi_private-cpu_dai_drv.symmetric_rates = 1;
 +if (!fsl_ssi_is_ac97(ssi_private))
 +ssi_private-cpu_dai_drv.symmetric_rates = 1;
 +
 
 Is this necessary?  Why not just add fsl,ssi-asynchronous to the AC97 device 
 tree node?

Because in the AC'97 mode the driver supports only one channel config and one 
sample format
anyway the remaining settings controlled by this property don't do anything.

Since it should be safe to enable asymmetric rates with any AC'97 CODEC I think 
it is good
to do it in driver than to add fsl,ssi-asynchronous to every AC'97 DT node.

Also the description of this property in fsl,ssi.txt looks like that it only 
makes sense in
non-AC'97 mode.

Best regards,
Maciej Szmigiero

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] ASoC: codecs: use SNDRV_PCM_FMTBIT_* for format bitmask

2015-05-23 Thread Maciej S. Szmigiero
snd_soc_pcm_stream.formats is a bitmask of SNDRV_PCM_FMTBIT_*,
not of SNDRV_PCM_FORMAT_* (which are sequential integers),
however some of ASoC CODEC drivers use these values instead.

Found out by sparse on 0-day kernel tester.

Signed-off-by: Maciej Szmigiero m...@maciej.szmigiero.name

diff --git a/sound/soc/codecs/88pm860x-codec.c 
b/sound/soc/codecs/88pm860x-codec.c
index ee31fa7..38b3dad 100644
--- a/sound/soc/codecs/88pm860x-codec.c
+++ b/sound/soc/codecs/88pm860x-codec.c
@@ -1186,16 +1186,16 @@ static struct snd_soc_dai_driver pm860x_dai[] = {
.channels_min   = 2,
.channels_max   = 2,
.rates  = PM860X_RATES,
-   .formats= SNDRV_PCM_FORMAT_S16_LE | \
- SNDRV_PCM_FORMAT_S18_3LE,
+   .formats= SNDRV_PCM_FMTBIT_S16_LE | \
+ SNDRV_PCM_FMTBIT_S18_3LE,
},
.capture = {
.stream_name= PCM Capture,
.channels_min   = 2,
.channels_max   = 2,
.rates  = PM860X_RATES,
-   .formats= SNDRV_PCM_FORMAT_S16_LE | \
- SNDRV_PCM_FORMAT_S18_3LE,
+   .formats= SNDRV_PCM_FMTBIT_S16_LE | \
+ SNDRV_PCM_FMTBIT_S18_3LE,
},
.ops= pm860x_pcm_dai_ops,
}, {
@@ -1207,16 +1207,16 @@ static struct snd_soc_dai_driver pm860x_dai[] = {
.channels_min   = 2,
.channels_max   = 2,
.rates  = SNDRV_PCM_RATE_8000_48000,
-   .formats= SNDRV_PCM_FORMAT_S16_LE | \
- SNDRV_PCM_FORMAT_S18_3LE,
+   .formats= SNDRV_PCM_FMTBIT_S16_LE | \
+ SNDRV_PCM_FMTBIT_S18_3LE,
},
.capture = {
.stream_name= I2S Capture,
.channels_min   = 2,
.channels_max   = 2,
.rates  = SNDRV_PCM_RATE_8000_48000,
-   .formats= SNDRV_PCM_FORMAT_S16_LE | \
- SNDRV_PCM_FORMAT_S18_3LE,
+   .formats= SNDRV_PCM_FMTBIT_S16_LE | \
+ SNDRV_PCM_FMTBIT_S18_3LE,
},
.ops= pm860x_i2s_dai_ops,
},
diff --git a/sound/soc/codecs/stac9766.c b/sound/soc/codecs/stac9766.c
index 2341e8e..ed4cca7 100644
--- a/sound/soc/codecs/stac9766.c
+++ b/sound/soc/codecs/stac9766.c
@@ -320,7 +320,7 @@ static struct snd_soc_dai_driver stac9766_dai[] = {
.channels_max = 2,
.rates = SNDRV_PCM_RATE_32000 | \
SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000,
-   .formats = SNDRV_PCM_FORMAT_IEC958_SUBFRAME_BE,
+   .formats = SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_BE,
},
/* alsa ops */
.ops = stac9766_dai_ops_digital,
diff --git a/sound/soc/codecs/wm8900.c b/sound/soc/codecs/wm8900.c
index e7d2ecd..493faf5 100644
--- a/sound/soc/codecs/wm8900.c
+++ b/sound/soc/codecs/wm8900.c
@@ -998,8 +998,8 @@ static int wm8900_digital_mute(struct snd_soc_dai 
*codec_dai, int mute)
  SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000)
 
 #define WM8900_PCM_FORMATS \
-   (SNDRV_PCM_FORMAT_S16_LE | SNDRV_PCM_FORMAT_S20_3LE | \
-SNDRV_PCM_FORMAT_S24_LE)
+   (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \
+SNDRV_PCM_FMTBIT_S24_LE)
 
 static const struct snd_soc_dai_ops wm8900_dai_ops = {
.hw_params  = wm8900_hw_params,
diff --git a/sound/soc/codecs/wm9713.c b/sound/soc/codecs/wm9713.c
index 9d18a0e..89cd2d6 100644
--- a/sound/soc/codecs/wm9713.c
+++ b/sound/soc/codecs/wm9713.c
@@ -1054,8 +1054,8 @@ static int ac97_aux_prepare(struct snd_pcm_substream 
*substream,
  SNDRV_PCM_RATE_48000)
 
 #define WM9713_PCM_FORMATS \
-   (SNDRV_PCM_FORMAT_S16_LE | SNDRV_PCM_FORMAT_S20_3LE | \
-SNDRV_PCM_FORMAT_S24_LE)
+   (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \
+SNDRV_PCM_FMTBIT_S24_LE)
 
 static const struct snd_soc_dai_ops wm9713_dai_ops_hifi = {
.prepare= ac97_hifi_prepare,
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] ASoC: codecs: use SNDRV_PCM_FMTBIT_* for format bitmask

2015-05-26 Thread Maciej S. Szmigiero
Hello Takashi,

W dniu 26.05.2015 07:29, Takashi Iwai pisze:
 At Sat, 23 May 2015 18:32:29 +0200,
 Maciej S. Szmigiero wrote:

 snd_soc_pcm_stream.formats is a bitmask of SNDRV_PCM_FMTBIT_*,
 not of SNDRV_PCM_FORMAT_* (which are sequential integers),
 however some of ASoC CODEC drivers use these values instead.

 Found out by sparse on 0-day kernel tester.

 Signed-off-by: Maciej Szmigiero m...@maciej.szmigiero.name
 
 Wow, that made me wonder how these drivers could actually work.

Maybe, by coincidence, the wrong defines contained enough bits
set to actually select some common, working format with their
controllers?

 BTW, how did you detect it?  Any static analyzer like sparse or
 smatch?  sparse didn't detect it at the last time I tried, IIRC...

I've received an e-mail from kbuild test robot at
0-DAY kernel test infrastructure that automated testing there
using sparse found this issue on wm9713 and stac9766 CODECs.

The exact warning was:
 sound/soc/codecs/stac9766.c:324:28: sparse: incorrect type in initializer 
 (different base types)
   sound/soc/codecs/stac9766.c:324:28:expected unsigned long long 
[unsigned] [usertype] formats
   sound/soc/codecs/stac9766.c:324:28:got restricted snd_pcm_format_t 
[usertype] noident

What is important the warning doesn't show unless a check build
is made with CF=-D__CHECK_ENDIAN__ .

Upon checking I've found the same issue also in two other CODECs,
which aren't normally being built on x86_64 (target architecture
for above automated build) even when SND_SOC_ALL_CODECS is selected.

 thanks,
 
 Takashi

Best regards,
Maciej Szmigiero

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/3] emu10k1: rename Audigy Analog Capture Boost control

2015-07-07 Thread Maciej S. Szmigiero
Audigy has Analog Capture Boost mixer control,
however now this only controls mic level, not
other analog sources.

It applies also both to playback and capture,
so rename it to something more descriptive.

Signed-off-by: Maciej Szmigiero m...@maciej.szmigiero.name
---
 sound/pci/emu10k1/emumixer.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/sound/pci/emu10k1/emumixer.c b/sound/pci/emu10k1/emumixer.c
index 567b5cb..076b117 100644
--- a/sound/pci/emu10k1/emumixer.c
+++ b/sound/pci/emu10k1/emumixer.c
@@ -1741,7 +1741,7 @@ static int snd_audigy_capture_boost_put(struct 
snd_kcontrol *kcontrol,
 static struct snd_kcontrol_new snd_audigy_capture_boost =
 {
.iface =SNDRV_CTL_ELEM_IFACE_MIXER,
-   .name = Analog Capture Boost,
+   .name = Mic Extra Boost,
.info = snd_audigy_capture_boost_info,
.get =  snd_audigy_capture_boost_get,
.put =  snd_audigy_capture_boost_put

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/3] emu10k1: enable TAD mic out on Audigy

2015-07-07 Thread Maciej S. Szmigiero
Enable TAD output on Audigy naming it Phone Output,
to be consistent with TAD input which is called Phone.

According to Creative doc
( http://support.creative.com/kb/ShowArticle.aspx?sid=3026 )
this should output just mic signal.

Signed-off-by: Maciej Szmigiero m...@maciej.szmigiero.name
---
 sound/pci/emu10k1/emumixer.c |   12 +++-
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/sound/pci/emu10k1/emumixer.c b/sound/pci/emu10k1/emumixer.c
index f1cb7b3..567b5cb 100644
--- a/sound/pci/emu10k1/emumixer.c
+++ b/sound/pci/emu10k1/emumixer.c
@@ -1819,8 +1819,6 @@ int snd_emu10k1_mixer(struct snd_emu10k1 *emu,
 * the Philips ADC for 24bit capture */
PCM Playback Switch,
PCM Playback Volume,
-   Master Mono Playback Switch,
-   Master Mono Playback Volume,
Master Playback Switch,
Master Playback Volume,
PCM Out Path  Mute,
@@ -1848,6 +1846,8 @@ int snd_emu10k1_mixer(struct snd_emu10k1 *emu,
/* Wave Capture Volume, PCM Capture Volume, */
Wave Master Playback Volume, Master Playback Volume,
AMic Playback Volume, Mic Playback Volume,
+   Master Mono Playback Switch, Phone Output Playback Switch,
+   Master Mono Playback Volume, Phone Output Playback Volume,
NULL
};
static char *audigy_rename_ctls_i2c_adc[] = {
@@ -1873,8 +1873,6 @@ int snd_emu10k1_mixer(struct snd_emu10k1 *emu,
 * the Philips ADC for 24bit capture */
PCM Playback Switch,
PCM Playback Volume,
-   Master Mono Playback Switch,
-   Master Mono Playback Volume,
Capture Source,
Capture Switch,
Capture Volume,
@@ -1906,7 +1904,8 @@ int snd_emu10k1_mixer(struct snd_emu10k1 *emu,
Aux Playback Volume, Aux Capture Volume,
Video Playback Switch, Video Capture Switch,
Video Playback Volume, Video Capture Volume,
-
+   Master Mono Playback Switch, Phone Output Playback Switch,
+   Master Mono Playback Volume, Phone Output Playback Volume,
NULL
};
 
@@ -1941,6 +1940,9 @@ int snd_emu10k1_mixer(struct snd_emu10k1 *emu,
snd_ac97_write_cache(emu-ac97, AC97_MASTER, 0x);
/* set capture source to mic */
snd_ac97_write_cache(emu-ac97, AC97_REC_SEL, 0x);
+   /* set mono output (TAD) to mic */
+   snd_ac97_update_bits(emu-ac97, AC97_GENERAL_PURPOSE,
+   0x0200, 0x0200);
if (emu-card_capabilities-adc_1361t)
c = audigy_remove_ctls_1361t_adc;
else 
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/3] emu10k1: remove unused AC'97 mixer controls on Audigy

2015-07-07 Thread Maciej S. Szmigiero
AC'97 Headphone output and EAPD control aren't used
on Audigy so remove them from mixer.

Also remove AC'97 3D control as the driver is
already doing for Audigys with 1361T ADC.

Signed-off-by: Maciej Szmigiero m...@maciej.szmigiero.name
---
 sound/pci/emu10k1/emumixer.c |   11 ++-
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/sound/pci/emu10k1/emumixer.c b/sound/pci/emu10k1/emumixer.c
index 55e5716..f1cb7b3 100644
--- a/sound/pci/emu10k1/emumixer.c
+++ b/sound/pci/emu10k1/emumixer.c
@@ -1830,10 +1830,16 @@ int snd_emu10k1_mixer(struct snd_emu10k1 *emu,
Capture Switch,
Capture Volume,
Mic Select,
+   Headphone Playback Switch,
+   Headphone Playback Volume,
+   3D Control - Center,
+   3D Control - Depth,
+   3D Control - Switch,
Video Playback Switch,
Video Playback Volume,
Mic Playback Switch,
Mic Playback Volume,
+   External Amplifier,
NULL
};
static char *audigy_rename_ctls[] = {
@@ -1996,11 +2002,6 @@ int snd_emu10k1_mixer(struct snd_emu10k1 *emu,
rename_ctl(card, Analog Mix Capture Volume, Line2 Capture 
Volume);
rename_ctl(card, Aux2 Capture Volume, Line3 Capture Volume);
rename_ctl(card, Mic Capture Volume, Unknown1 Capture 
Volume);
-   remove_ctl(card, Headphone Playback Switch);
-   remove_ctl(card, Headphone Playback Volume);
-   remove_ctl(card, 3D Control - Center);
-   remove_ctl(card, 3D Control - Depth);
-   remove_ctl(card, 3D Control - Switch);
}
if ((kctl = emu-ctl_send_routing = 
snd_ctl_new1(snd_emu10k1_send_routing_control, emu)) == NULL)
return -ENOMEM;
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] drm: panel-simple: add URT UMSH-8596MD-xT panel support

2015-07-29 Thread Maciej S. Szmigiero
This patch adds support for United Radiant Technology
UMSH-8596MD-xT 7.0 WVGA TFT LCD panels
(both LVDS and parallel versions) to DRM
panel-simple driver.

Signed-off-by: Maciej Szmigiero m...@maciej.szmigiero.name
---
 .../devicetree/bindings/panel/urt,umsh-8596md.txt  |   11 +
 .../devicetree/bindings/vendor-prefixes.txt|1 +
 drivers/gpu/drm/panel/panel-simple.c   |   42 
 3 files changed, 54 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/panel/urt,umsh-8596md.txt

diff --git a/Documentation/devicetree/bindings/panel/urt,umsh-8596md.txt 
b/Documentation/devicetree/bindings/panel/urt,umsh-8596md.txt
new file mode 100644
index 000..2990e6b
--- /dev/null
+++ b/Documentation/devicetree/bindings/panel/urt,umsh-8596md.txt
@@ -0,0 +1,11 @@
+United Radiant Technology UMSH-8596MD-xT 7.0 WVGA TFT LCD panel
+
+Supported are LVDS versions (-11T, -19T) and parallel ones
+(-T, -1T, -7T, -20T).
+
+Required properties:
+- compatible: should be urt,umsh-8596md-lvds for LVDS versions,
+  urt,umsh-8596md-parallel for parallel ones.
+
+This binding is compatible with the simple-panel binding, which is specified
+in simple-panel.txt in this directory.
diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
b/Documentation/devicetree/bindings/vendor-prefixes.txt
index d247994..f2bb617 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -212,6 +212,7 @@ toshiba Toshiba Corporation
 toumaz Toumaz
 tplink TP-LINK Technologies Co., Ltd.
 truly  Truly Semiconductors Limited
+urtUnited Radiant Technology Corporation
 usiUniversal Scientific Industrial Co., Ltd.
 v3 V3 Semiconductor
 variscite  Variscite Ltd.
diff --git a/drivers/gpu/drm/panel/panel-simple.c 
b/drivers/gpu/drm/panel/panel-simple.c
index f94201b..be47fd7 100644
--- a/drivers/gpu/drm/panel/panel-simple.c
+++ b/drivers/gpu/drm/panel/panel-simple.c
@@ -1036,6 +1036,42 @@ static const struct panel_desc shelly_sca07010_bfn_lnn = 
{
.bus_format = MEDIA_BUS_FMT_RGB666_1X18,
 };
 
+static const struct display_timing urt_umsh_8596md_timing = {
+   .pixelclock = { 3326, 3326, 3326 },
+   .hactive = { 800, 800, 800 },
+   .hfront_porch = { 41, 41, 41 },
+   .hback_porch = { 216 - 128, 216 - 128, 216 - 128 },
+   .hsync_len = { 71, 128, 128 },
+   .vactive = { 480, 480, 480 },
+   .vfront_porch = { 10, 10, 10 },
+   .vback_porch = { 35 - 2, 35 - 2, 35 - 2 },
+   .vsync_len = { 2, 2, 2 },
+   .flags = DISPLAY_FLAGS_DE_HIGH | DISPLAY_FLAGS_PIXDATA_NEGEDGE |
+   DISPLAY_FLAGS_HSYNC_LOW | DISPLAY_FLAGS_VSYNC_LOW,
+};
+
+static const struct panel_desc urt_umsh_8596md_lvds = {
+   .timings = urt_umsh_8596md_timing,
+   .num_timings = 1,
+   .bpc = 6,
+   .size = {
+   .width = 152,
+   .height = 91,
+   },
+   .bus_format = MEDIA_BUS_FMT_RGB666_1X7X3_SPWG,
+};
+
+static const struct panel_desc urt_umsh_8596md_parallel = {
+   .timings = urt_umsh_8596md_timing,
+   .num_timings = 1,
+   .bpc = 6,
+   .size = {
+   .width = 152,
+   .height = 91,
+   },
+   .bus_format = MEDIA_BUS_FMT_RGB666_1X18,
+};
+
 static const struct of_device_id platform_of_match[] = {
{
.compatible = ampire,am800480r3tmqwa1h,
@@ -1125,6 +1161,12 @@ static const struct of_device_id platform_of_match[] = {
.compatible = shelly,sca07010-bfn-lnn,
.data = shelly_sca07010_bfn_lnn,
}, {
+   .compatible = urt,umsh-8596md-lvds,
+   .data = urt_umsh_8596md_lvds,
+   }, {
+   .compatible = urt,umsh-8596md-parallel,
+   .data = urt_umsh_8596md_parallel,
+   }, {
/* sentinel */
}
 };
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 6/6] ASoC: fsl_ssi: adjust set DAI format in AC'97 mode

2015-07-30 Thread Maciej S. Szmigiero
Adjust set DAI format function in fsl_ssi driver so it
doesn't fail and clears RXDIR in AC'97 mode.

Signed-off-by: Maciej Szmigiero m...@maciej.szmigiero.name
---
 sound/soc/fsl/fsl_ssi.c |8 +---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index 8e5ff5e..37aabe3 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -900,14 +900,16 @@ static int _fsl_ssi_set_dai_fmt(struct device *dev,
scr = ~CCSR_SSI_SCR_SYS_CLK_EN;
break;
default:
-   return -EINVAL;
+   if (!fsl_ssi_is_ac97(ssi_private))
+   return -EINVAL;
}
 
stcr |= strcr;
srcr |= strcr;
 
-   if (ssi_private-cpu_dai_drv.symmetric_rates) {
-   /* Need to clear RXDIR when using SYNC mode */
+   if (ssi_private-cpu_dai_drv.symmetric_rates
+   || fsl_ssi_is_ac97(ssi_private)) {
+   /* Need to clear RXDIR when using SYNC or AC97 mode */
srcr = ~CCSR_SSI_SRCR_RXDIR;
scr |= CCSR_SSI_SCR_SYN;
}

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 5/6] ASoC: fsl_ssi: instantiate AC'97 CODEC

2015-07-30 Thread Maciej S. Szmigiero
Instantiate AC'97 CODEC in fsl_ssi driver AC'97 mode.

Signed-off-by: Maciej Szmigiero m...@maciej.szmigiero.name
---
 sound/soc/fsl/fsl_ssi.c |   21 +
 1 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index 154bcf6..8e5ff5e 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -1460,6 +1460,27 @@ done:
_fsl_ssi_set_dai_fmt(pdev-dev, ssi_private,
 ssi_private-dai_fmt);
 
+   if (fsl_ssi_is_ac97(ssi_private)) {
+   u32 ssi_idx;
+
+   ret = of_property_read_u32(np, cell-index, ssi_idx);
+   if (ret) {
+   dev_err(pdev-dev, cannot get SSI index property\n);
+   goto error_sound_card;
+   }
+
+   ssi_private-pdev =
+   platform_device_register_data(NULL,
+   ac97-codec, ssi_idx, NULL, 0);
+   if (IS_ERR(ssi_private-pdev)) {
+   ret = PTR_ERR(ssi_private-pdev);
+   dev_err(pdev-dev,
+   failed to register AC97 codec platform: %d\n,
+   ret);
+   goto error_sound_card;
+   }
+   }
+
return 0;
 
 error_sound_card:

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 4/6] ASoC: fsl_ssi: add AC'97 ops setting check and cleanup

2015-07-30 Thread Maciej S. Szmigiero
Check whether setting AC'97 ops succeeded and clean them
on removal so the fsl_ssi driver can be reloaded.

Signed-off-by: Maciej Szmigiero m...@maciej.szmigiero.name
---
 sound/soc/fsl/fsl_ssi.c |9 -
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index 7f4f0b9..154bcf6 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -1340,7 +1340,11 @@ static int fsl_ssi_probe(struct platform_device *pdev)
 
fsl_ac97_data = ssi_private;
 
-   snd_soc_set_ac97_ops_of_reset(fsl_ssi_ac97_ops, pdev);
+   ret = snd_soc_set_ac97_ops_of_reset(fsl_ssi_ac97_ops, pdev);
+   if (ret) {
+   dev_err(pdev-dev, could not set AC'97 ops\n);
+   return ret;
+   }
} else {
/* Initialize this copy of the CPU DAI driver structure */
memcpy(ssi_private-cpu_dai_drv, fsl_ssi_dai_template,
@@ -1480,6 +1484,9 @@ static int fsl_ssi_remove(struct platform_device *pdev)
if (ssi_private-soc-imx)
fsl_ssi_imx_clean(pdev, ssi_private);
 
+   if (fsl_ssi_is_ac97(ssi_private))
+   snd_soc_set_ac97_ops(NULL);
+
return 0;
 }
 

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/6] ASoC: fsl_ssi: enable IPG clock during AC'97 reg access

2015-07-30 Thread Maciej S. Szmigiero
IPG clock have to be enabled during AC'97 CODEC register
access in fsl_ssi driver.

Signed-off-by: Maciej Szmigiero m...@maciej.szmigiero.name
---
 sound/soc/fsl/fsl_ssi.c |   19 +++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index 484ff20..8185edc 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -1127,10 +1127,17 @@ static void fsl_ssi_ac97_write(struct snd_ac97 *ac97, 
unsigned short reg,
struct regmap *regs = fsl_ac97_data-regs;
unsigned int lreg;
unsigned int lval;
+   int ret;
 
if (reg  0x7f)
return;
 
+   ret = clk_prepare_enable(fsl_ac97_data-clk);
+   if (ret) {
+   pr_err(ac97 write clk_prepare_enable failed: %d\n,
+   ret);
+   return;
+   }
 
lreg = reg   12;
regmap_write(regs, CCSR_SSI_SACADD, lreg);
@@ -1141,6 +1148,8 @@ static void fsl_ssi_ac97_write(struct snd_ac97 *ac97, 
unsigned short reg,
regmap_update_bits(regs, CCSR_SSI_SACNT, CCSR_SSI_SACNT_RDWR_MASK,
CCSR_SSI_SACNT_WR);
udelay(100);
+
+   clk_disable_unprepare(fsl_ac97_data-clk);
 }
 
 static unsigned short fsl_ssi_ac97_read(struct snd_ac97 *ac97,
@@ -1151,6 +1160,14 @@ static unsigned short fsl_ssi_ac97_read(struct snd_ac97 
*ac97,
unsigned short val = -1;
u32 reg_val;
unsigned int lreg;
+   int ret;
+
+   ret = clk_prepare_enable(fsl_ac97_data-clk);
+   if (ret) {
+   pr_err(ac97 read clk_prepare_enable failed: %d\n,
+   ret);
+   return -1;
+   }
 
lreg = (reg  0x7f)   12;
regmap_write(regs, CCSR_SSI_SACADD, lreg);
@@ -1162,6 +1179,8 @@ static unsigned short fsl_ssi_ac97_read(struct snd_ac97 
*ac97,
regmap_read(regs, CCSR_SSI_SACDAT, reg_val);
val = (reg_val  4)  0x;
 
+   clk_disable_unprepare(fsl_ac97_data-clk);
+
return val;
 }
 

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/6] ASoC: fsl_ssi: enable AC'97 asymmetric rates

2015-07-30 Thread Maciej S. Szmigiero
AC'97 bus can support asymmetric playback/capture rates
so enable them in this case in fsl_ssi driver.

Signed-off-by: Maciej Szmigiero m...@maciej.szmigiero.name
---
 sound/soc/fsl/fsl_ssi.c |4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index a83b900..7f4f0b9 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -1377,7 +1377,9 @@ static int fsl_ssi_probe(struct platform_device *pdev)
 
/* Are the RX and the TX clocks locked? */
if (!of_find_property(np, fsl,ssi-asynchronous, NULL)) {
-   ssi_private-cpu_dai_drv.symmetric_rates = 1;
+   if (!fsl_ssi_is_ac97(ssi_private))
+   ssi_private-cpu_dai_drv.symmetric_rates = 1;
+
ssi_private-cpu_dai_drv.symmetric_channels = 1;
ssi_private-cpu_dai_drv.symmetric_samplebits = 1;
}

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/6] ASoC: fsl_ssi: AC'97 DAI driver needs probe method too

2015-07-30 Thread Maciej S. Szmigiero
AC'97 DAI driver struct need the same probe method as
I2S one to setup DMA params in fsl_ssi driver.

Signed-off-by: Maciej Szmigiero m...@maciej.szmigiero.name
---
 sound/soc/fsl/fsl_ssi.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index 8185edc..a83b900 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -1101,6 +1101,7 @@ static const struct snd_soc_component_driver 
fsl_ssi_component = {
 
 static struct snd_soc_dai_driver fsl_ssi_ac97_dai = {
.bus_control = true,
+   .probe = fsl_ssi_dai_probe,
.playback = {
.stream_name = AC97 Playback,
.channels_min = 2,

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/6] ASoC: fsl_ssi: enable IPG clock during AC'97 reg access

2015-07-30 Thread Maciej S. Szmigiero
Hi Fabio,

On 30.07.2015 17:20, Fabio Estevam wrote:
 Hi Maciej,
 
 On Thu, Jul 30, 2015 at 11:33 AM, Maciej S. Szmigiero
 m...@maciej.szmigiero.name wrote:
 
  static unsigned short fsl_ssi_ac97_read(struct snd_ac97 *ac97,
 @@ -1151,6 +1160,14 @@ static unsigned short fsl_ssi_ac97_read(struct 
 snd_ac97 *ac97,
 unsigned short val = -1;
 u32 reg_val;
 unsigned int lreg;
 +   int ret;
 +
 +   ret = clk_prepare_enable(fsl_ac97_data-clk);
 +   if (ret) {
 +   pr_err(ac97 read clk_prepare_enable failed: %d\n,
 +   ret);
 +   return -1;
 
 return ret, please.
 

This function normal return value is an AC'97 register value,
so isn't more appropriate to return 0x in case of error
than linux error code?

Best regards,
Maciej Szmigiero

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 5/6] ASoC: fsl_ssi: instantiate AC'97 CODEC

2015-07-31 Thread Maciej S. Szmigiero
On 31.07.2015 07:46, Markus Pargmann wrote:
 On Thu, Jul 30, 2015 at 04:35:23PM +0200, Maciej S. Szmigiero wrote:
 Instantiate AC'97 CODEC in fsl_ssi driver AC'97 mode.

 Signed-off-by: Maciej Szmigiero m...@maciej.szmigiero.name
 ---
  sound/soc/fsl/fsl_ssi.c |   21 +
  1 files changed, 21 insertions(+), 0 deletions(-)

 diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
 index 154bcf6..8e5ff5e 100644
 --- a/sound/soc/fsl/fsl_ssi.c
 +++ b/sound/soc/fsl/fsl_ssi.c
 @@ -1460,6 +1460,27 @@ done:
  _fsl_ssi_set_dai_fmt(pdev-dev, ssi_private,
   ssi_private-dai_fmt);
  
 +if (fsl_ssi_is_ac97(ssi_private)) {
 +u32 ssi_idx;
 +
 +ret = of_property_read_u32(np, cell-index, ssi_idx);
 
 This property is not set anywhere in the imx* DTs.

That's right, but it is documented as required property in sound/fsl,ssi.txt:
 Required properties:
 (..)
 - cell-index:   The SSI, 0 = SSI1, 1 = SSI2, and so on.

 
 +if (ret) {
 +dev_err(pdev-dev, cannot get SSI index property\n);
 +goto error_sound_card;
 +}
 +
 +ssi_private-pdev =
 +platform_device_register_data(NULL,
 +ac97-codec, ssi_idx, NULL, 0);
 
 If you really want to create a device at this point you should use
 PLATFORM_DEVID_AUTO. I would prefer something where this is created in
 DT. On the other side it is a discoverable bus..

In the original implementation the codec was instantiated in DT but
the feedback was that this is wrong since devices on discoverable
buses shouldn't be in DT.

The platform device index is based on SSI index since the sound
card driver (fsl-asoc-card) has to know CODEC device name to identify
it in DAI links - as the only identification options seem to be either
DT node of CODEC or its device name.

That's why the (platform) device name has to be deterministic
if there is no mechanism to pass it from controller driver
to sound card driver.

 Regards,
 
 Markus

Best regards,
Maciej Szmigiero

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 3/6] ASoC: fsl_ssi: enable AC'97 asymmetric rates

2015-07-31 Thread Maciej S. Szmigiero
Hi Markus,

Thanks for looking into the changes.

On 31.07.2015 07:53, Markus Pargmann wrote:
 On Fri, Jul 31, 2015 at 07:27:19AM +0200, Markus Pargmann wrote:
 Hi,

 On Thu, Jul 30, 2015 at 04:34:19PM +0200, Maciej S. Szmigiero wrote:
 AC'97 bus can support asymmetric playback/capture rates
 so enable them in this case in fsl_ssi driver.

 Signed-off-by: Maciej Szmigiero m...@maciej.szmigiero.name
 ---
  sound/soc/fsl/fsl_ssi.c |4 +++-
  1 files changed, 3 insertions(+), 1 deletions(-)

 diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
 index a83b900..7f4f0b9 100644
 --- a/sound/soc/fsl/fsl_ssi.c
 +++ b/sound/soc/fsl/fsl_ssi.c
 @@ -1377,7 +1377,9 @@ static int fsl_ssi_probe(struct platform_device *pdev)
  
 /* Are the RX and the TX clocks locked? */
 if (!of_find_property(np, fsl,ssi-asynchronous, NULL)) {
 -   ssi_private-cpu_dai_drv.symmetric_rates = 1;
 +   if (!fsl_ssi_is_ac97(ssi_private))
 +   ssi_private-cpu_dai_drv.symmetric_rates = 1;
 +

 Why don't you use the DT property that is parsed here to enable
 asymmetric rates?

Because in the AC'97 mode the driver supports only one channel config and one 
sample format
anyway the remaining settings controlled by this property don't do anything.

Since it should be safe to enable asymmetric rates with any AC'97 CODEC I think 
it is good
to do it in driver than to add fsl,ssi-asynchronous to every AC'97 DT node.

Also the description of this property in fsl,ssi.txt looks like that it only 
makes sense in
non-AC'97 mode.

 Just found the last version of this series. Please use v2 and describe
 changes for a new iteration of a series.

This is just a resubmission, there are no functional differences since
it was originally submitted a month ago. 

 There is also a different setup with AC97 which does not use DMA. See
 the long comment at the top of the file about how ac97 is already used.

I understand that the problem with FIQ handler described in comment
on top of fsl_ssi.c only pertains incoming data, that is capture.

This patch effectively does not touch capture rates as they are already
limited to 48kHz only since this is the only capture rate defined in
fsl_ssi AC'97 DAI driver capture capabilities.

 Regards,
 
 Markus

Best regards,
Maciej Szmigiero

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] serial: don't announce CIR serial ports

2015-08-02 Thread Maciej S. Szmigiero
CIR type serial ports aren't real serial ports.
This is just a way to prevent legacy serial driver
from probing and eventually binding some resources
so don't announce them like normal serial ports.

Signed-off-by: Maciej Szmigiero m...@maciej.szmigiero.name
---
 drivers/tty/serial/serial_core.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index f368520..99f944d 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -2237,7 +2237,7 @@ uart_configure_port(struct uart_driver *drv, struct 
uart_state *state,
port-ops-config_port(port, flags);
}
 
-   if (port-type != PORT_UNKNOWN) {
+   if (port-type != PORT_UNKNOWN  port-type != PORT_8250_CIR) {
unsigned long flags;
 
uart_report_port(drv, port);
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] serial: 8250: don't bind to SMSC IrCC IR port

2015-08-02 Thread Maciej S. Szmigiero
SMSC IrCC SIR/FIR port should not be bound to by
(legacy) serial driver so its own driver (smsc-ircc2)
can bind to it.

Signed-off-by: Maciej Szmigiero m...@maciej.szmigiero.name
---
 drivers/tty/serial/8250/8250_pnp.c |5 +
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_pnp.c 
b/drivers/tty/serial/8250/8250_pnp.c
index 50a09cd..61fd3d3 100644
--- a/drivers/tty/serial/8250/8250_pnp.c
+++ b/drivers/tty/serial/8250/8250_pnp.c
@@ -364,6 +364,11 @@ static const struct pnp_device_id pnp_dev_table[] = {
/* Winbond CIR port, should not be probed. We should keep track
   of it to prevent the legacy serial driver from probing it */
{   WEC1022,  CIR_PORT},
+   /*
+* SMSC IrCC SIR/FIR port, should not be probed by serial driver
+* as well so its own driver can bind to it.
+*/
+   {   SMCF010,  CIR_PORT},
{   , 0   }
 };
 
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] serial: 8250: bind to ALi Fast Infrared Controller (ALI5123)

2015-08-02 Thread Maciej S. Szmigiero
This way this device can be used with irtty-sir -
at least on Toshiba Satellite A20-S103 it is not configured by default
and needs PNP activation before it starts to respond on I/O ports.

This device has actually its own driver (ali-ircc),
but this driver seems to be non-functional for a very long time
(see http://permalink.gmane.org/gmane.linux.irda.general/484
http://permalink.gmane.org/gmane.network.protocols.obex.openobex.user/943
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=535070 ).

Signed-off-by: Maciej Szmigiero m...@maciej.szmigiero.name
---
 drivers/acpi/acpi_pnp.c|1 +
 drivers/tty/serial/8250/8250_pnp.c |6 ++
 2 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/drivers/acpi/acpi_pnp.c b/drivers/acpi/acpi_pnp.c
index ff6d8ad..fb76552 100644
--- a/drivers/acpi/acpi_pnp.c
+++ b/drivers/acpi/acpi_pnp.c
@@ -153,6 +153,7 @@ static const struct acpi_device_id acpi_pnp_device_ids[] = {
{AEI0250},/* PROLiNK 1456VH ISA PnP K56flex Fax Modem */
{AEI1240},/* Actiontec ISA PNP 56K X2 Fax Modem */
{AKY1021},/* Rockwell 56K ACF II Fax+Data+Voice Modem */
+   {ALI5123},/* ALi Fast Infrared Controller */
{AZT4001},/* AZT3005 PnP SOUND DEVICE */
{BDP3336},/* Best Data Products Inc. Smart One 336F PnP 
Modem */
{BRI0A49},/* Boca Complete Ofc Communicator 14.4 Data-FAX 
*/
diff --git a/drivers/tty/serial/8250/8250_pnp.c 
b/drivers/tty/serial/8250/8250_pnp.c
index 61fd3d3..658b392 100644
--- a/drivers/tty/serial/8250/8250_pnp.c
+++ b/drivers/tty/serial/8250/8250_pnp.c
@@ -41,6 +41,12 @@ static const struct pnp_device_id pnp_dev_table[] = {
{   AEI1240,  0   },
/* Rockwell 56K ACF II Fax+Data+Voice Modem */
{   AKY1021,  0 /*SPCI_FL_NO_SHIRQ*/  },
+   /*
+* ALi Fast Infrared Controller
+* Native driver (ali-ircc) is broken so at least
+* it can be used with irtty-sir.
+*/
+   {   ALI5123,  0   },
/* AZT3005 PnP SOUND DEVICE */
{   AZT4001,  0   },
/* Best Data Products Inc. Smart One 336F PnP Modem */
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 6/6 v2] ASoC: fsl_ssi: adjust set DAI format in AC'97 mode

2015-08-02 Thread Maciej S. Szmigiero
Adjust set DAI format function in fsl_ssi driver
so it doesn't fail and clears RXDIR in AC'97 mode.

Changes from v1: fix indentation to be consistent with rest
of the driver.

Signed-off-by: Maciej Szmigiero m...@maciej.szmigiero.name
---
 sound/soc/fsl/fsl_ssi.c |8 +---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index 8e5ff5e..1ba63bd 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -900,14 +900,16 @@ static int _fsl_ssi_set_dai_fmt(struct device *dev,
scr = ~CCSR_SSI_SCR_SYS_CLK_EN;
break;
default:
-   return -EINVAL;
+   if (!fsl_ssi_is_ac97(ssi_private))
+   return -EINVAL;
}
 
stcr |= strcr;
srcr |= strcr;
 
-   if (ssi_private-cpu_dai_drv.symmetric_rates) {
-   /* Need to clear RXDIR when using SYNC mode */
+   if (ssi_private-cpu_dai_drv.symmetric_rates
+   || fsl_ssi_is_ac97(ssi_private)) {
+   /* Need to clear RXDIR when using SYNC or AC97 mode */
srcr = ~CCSR_SSI_SRCR_RXDIR;
scr |= CCSR_SSI_SCR_SYN;
}

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 6/6 v2] ASoC: fsl_ssi: adjust set DAI format in AC'97 mode

2015-08-03 Thread Maciej S. Szmigiero
On 03.08.2015 18:21, Mark Brown wrote:
 On Mon, Aug 03, 2015 at 12:44:11AM +0200, Maciej S. Szmigiero wrote:
 Adjust set DAI format function in fsl_ssi driver
 so it doesn't fail and clears RXDIR in AC'97 mode.

 Changes from v1: fix indentation to be consistent with rest
 of the driver.
 
 Inter version changelogs go after the --- as covered in
 SubmittingPatches.
 

 Signed-off-by: Maciej Szmigiero m...@maciej.szmigiero.name
 
 Please don't bury new patches in reply to old submissions, especially
 not individual patches - it makes it hard to work out what's going on
 and make sure that the most current version of everything is being
 applied.  In order to avoid confusion I'm not going to look at these,
 please resubmit as a new thread.
 
 Please also try to thread your patch series together (git send-email can
 do this for you) - it also helps people keep track of things.

Thanks for information.

In cases like this where only one patch of six patch series is updated
should other ones be resubmitted as well to keep the full patch series
together?

Best regards,
Maciej Szmigiero

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] serial: don't announce CIR serial ports

2015-08-03 Thread Maciej S. Szmigiero
On 04.08.2015 01:40, Greg Kroah-Hartman wrote:
 On Sun, Aug 02, 2015 at 11:09:57PM +0200, Maciej S. Szmigiero wrote:
 CIR type serial ports aren't real serial ports.
 This is just a way to prevent legacy serial driver
 from probing and eventually binding some resources
 so don't announce them like normal serial ports.

 Signed-off-by: Maciej Szmigiero m...@maciej.szmigiero.name
 ---
  drivers/tty/serial/serial_core.c |2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)

 diff --git a/drivers/tty/serial/serial_core.c 
 b/drivers/tty/serial/serial_core.c
 index f368520..99f944d 100644
 --- a/drivers/tty/serial/serial_core.c
 +++ b/drivers/tty/serial/serial_core.c
 @@ -2237,7 +2237,7 @@ uart_configure_port(struct uart_driver *drv, struct 
 uart_state *state,
  port-ops-config_port(port, flags);
  }
  
 -if (port-type != PORT_UNKNOWN) {
 +if (port-type != PORT_UNKNOWN  port-type != PORT_8250_CIR) {
  unsigned long flags;
  
  uart_report_port(drv, port);
 
 This does not seem correct, why is this type of port somehow special
 that it should be skiped?

PORT_8250_CIR is not an actual serial port, it is a way to tell serial driver
to not really bind to some resources (I/O port, memory range, IRQ). 

The 8250 driver does scan a few predefined locations (I/O ports on x86) to
discover legacy serial ports there.

The problem is that some of devices that shouldn't been driven by 8250 driver
implement enough of serial port interface to be identified as a serial port
(and bound to) during this scan by this driver.
This prevents their native driver from binding to them since their resources
are already taken.

When a serial port has PORT_8250_CIR type the relevant resources won't be
reserved by 8250 driver and trying to use this port will result in ENODEV or
EIO (drivers/tty/serial/8250/8250_core.c:serial8250_do_startup()
returns -ENODEV unconditionally for such type of port).

Marking port as PORT_8250_CIR type is done by 8250 PNP driver which
will do this for a some of PNP IDs
(besides marking them it also won't bind to these devices).

Currently only Winbond CIR port PNP ID is on the list,
but I have also submitted other patch to add SMSC IR port too, as it has the
same problem.

Overall, I guess the announcement purpose is for user to tell him what serial
ports he has on the system, and by extension, which ones he can use.
Since user can't really use this type of serial port it would be nice to not
announce it.
That's why I've submitted this patch.

 thanks,
 
 greg k-h
 

Thanks and best regards,
Maciej Szmigiero

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 6/6] ASoC: fsl_ssi: adjust set DAI format in AC'97 mode

2015-07-31 Thread Maciej S. Szmigiero
On 31.07.2015 07:58, Markus Pargmann wrote:
 On Thu, Jul 30, 2015 at 04:35:58PM +0200, Maciej S. Szmigiero wrote:
 Adjust set DAI format function in fsl_ssi driver so it
 doesn't fail and clears RXDIR in AC'97 mode.

 Signed-off-by: Maciej Szmigiero m...@maciej.szmigiero.name
 ---
  sound/soc/fsl/fsl_ssi.c |8 +---
  1 files changed, 5 insertions(+), 3 deletions(-)

 diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
 index 8e5ff5e..37aabe3 100644
 --- a/sound/soc/fsl/fsl_ssi.c
 +++ b/sound/soc/fsl/fsl_ssi.c
 @@ -900,14 +900,16 @@ static int _fsl_ssi_set_dai_fmt(struct device *dev,
  scr = ~CCSR_SSI_SCR_SYS_CLK_EN;
  break;
  default:
 -return -EINVAL;
 +if (!fsl_ssi_is_ac97(ssi_private))
 +return -EINVAL;
 
 I think it would be better to add another case for the other mode which
 is supported (AC97) instead of using the default case.

This is a switch of DAI clock masters and AC'97 is none of them:
while case 0: can be added this would be very similar to the current code.

Alternatively, the whole switch statement could be wrapped inside
if (!fsl_ssi_is_ac97(ssi_private)) if that would be better
with regards to code style.

  }
  
  stcr |= strcr;
  srcr |= strcr;
  
 -if (ssi_private-cpu_dai_drv.symmetric_rates) {
 -/* Need to clear RXDIR when using SYNC mode */
 +if (ssi_private-cpu_dai_drv.symmetric_rates
 +|| fsl_ssi_is_ac97(ssi_private)) {
 
 Please fix this indention. Most of the driver is written with 2 tab
 indention after a line break and the new policy seems to be to indent on
 the opening bracket.

Will reindent this.

 
 Regards,
 
 Markus

Best regards,
Maciej Szmigiero

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] serial: don't register CIR serial ports

2015-08-05 Thread Maciej S. Szmigiero
CIR type serial ports aren't real serial ports.

This is just a way to prevent legacy 8250 serial
driver from probing and eventually binding some
resources.

Since in current state such ports aren't providing
any real functionality and it is not possible
to change their type via setserial/ioctl(TIOCSSERIAL)
(due to UPF_FIXED_PORT flag set on them)
it is simpler and cleaner to not register them at all
with serial core.

Print a short message in this case so it is known
to user what has happened.

This way checks for PORT_8250_CIR in serial port
callbacks can be removed too, since they won't
ever be called.

Signed-off-by: Maciej Szmigiero m...@maciej.szmigiero.name
---
This replaces serial: don't announce CIR serial ports
submission.

 drivers/tty/serial/8250/8250_core.c |   38 +-
 1 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_core.c 
b/drivers/tty/serial/8250/8250_core.c
index 37fff12..b843b83 100644
--- a/drivers/tty/serial/8250/8250_core.c
+++ b/drivers/tty/serial/8250/8250_core.c
@@ -2129,9 +2129,6 @@ int serial8250_do_startup(struct uart_port *port)
unsigned char lsr, iir;
int retval;
 
-   if (port-type == PORT_8250_CIR)
-   return -ENODEV;
-
if (!port-fifosize)
port-fifosize = uart_config[port-type].fifo_size;
if (!up-tx_loadsz)
@@ -2858,14 +2855,8 @@ static void serial8250_release_port(struct uart_port 
*port)
 static int serial8250_request_port(struct uart_port *port)
 {
struct uart_8250_port *up = up_to_u8250p(port);
-   int ret;
-
-   if (port-type == PORT_8250_CIR)
-   return -ENODEV;
-
-   ret = serial8250_request_std_resource(up);
 
-   return ret;
+   return serial8250_request_std_resource(up);
 }
 
 static int fcr_get_rxtrig_bytes(struct uart_8250_port *up)
@@ -3013,9 +3004,6 @@ static void serial8250_config_port(struct uart_port 
*port, int flags)
struct uart_8250_port *up = up_to_u8250p(port);
int ret;
 
-   if (port-type == PORT_8250_CIR)
-   return;
-
/*
 * Find the region that we can probe for.  This in turn
 * tells us whether we can probe for the type of port.
@@ -3889,13 +3877,25 @@ int serial8250_register_8250_port(struct uart_8250_port 
*up)
if (up-dl_write)
uart-dl_write = up-dl_write;
 
-   if (serial8250_isa_config != NULL)
-   serial8250_isa_config(0, uart-port,
-   uart-capabilities);
+   if (uart-port.type != PORT_8250_CIR) {
+   if (serial8250_isa_config != NULL)
+   serial8250_isa_config(0, uart-port,
+   uart-capabilities);
 
-   ret = uart_add_one_port(serial8250_reg, uart-port);
-   if (ret == 0)
-   ret = uart-port.line;
+   ret = uart_add_one_port(serial8250_reg,
+   uart-port);
+   if (ret == 0)
+   ret = uart-port.line;
+   } else {
+   pr_info(%s%sskipping CIR port at 0x%lx / 0x%llx, IRQ 
%d\n,
+   uart-port.dev ? dev_name(uart-port.dev) : ,
+   uart-port.dev ? :  : ,
+   uart-port.iobase,
+   (unsigned long long)uart-port.mapbase,
+   uart-port.irq);
+
+   ret = 0;
+   }
}
mutex_unlock(serial_mutex);
 

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] serial: don't announce CIR serial ports

2015-08-05 Thread Maciej S. Szmigiero
On 05.08.2015 04:03, Peter Hurley wrote:
 On 08/04/2015 07:25 PM, Maciej S. Szmigiero wrote:
 Hi Peter,

 Thanks for looking into it.

 On 04.08.2015 03:46, Peter Hurley wrote:
 Hi Maciej,

 On 08/02/2015 05:09 PM, Maciej S. Szmigiero wrote:
 CIR type serial ports aren't real serial ports.
 This is just a way to prevent legacy serial driver
 from probing and eventually binding some resources
 so don't announce them like normal serial ports.

 I'd like to keep some form of reporting so that we know the
 port was properly probed; what about extending uart_report_port()
 to including CIR + disabled status?

 Currently the printed message looks like this:
 00:01: ttyS2 at I/O 0x3e8 (irq = 7, base_baud = 115200) is a CIR port.

 I think it would be best to skip a device file name in this case,
 since this is how user sees (and uses) a real serial port.
 The message would be then:
 00:01 at I/O 0x3e8 (irq = 7, base_baud = 115200) is a CIR port.

 The dev name will always be present since the only current
 source of CIR ports is PNP 8250 driver which sets 
 dev pointer uncondtionally.

 Secondly, good catch! Because we should not be trying to
 register a console on this port, nor driving modem signals.

 So maybe an early exit after uart_report_port?

 All right, I will resubmit updated patch tomorrow.
 
 In re-reviewing this, I think the proper solution is actually not
 to add the uart port for a CIR port at all. It doesn't make
 sense because the tty cannot be changed by setserial/ioctl(TIOCSSERIAL),
 so the device node serves no purpose.
 
 This problem is really an artifact of the 8250 driver port management,
 and shouldn't involve the serial core at all.
 
 An additional benefit of this approach is that a simple one-line
 banner noting the port skip could be emitted instead from
 serial8250_register_8250_port().

That's a good idea, checks for PORT_8250_CIR in serial port
callbacks can be removed too this way, since these callbacks
won't ever be called.

I've submitted an updated patch.

 Regards,
 Peter Hurley
 
Best regards,
Maciej Szmigiero

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] serial: don't register CIR serial ports

2015-08-05 Thread Maciej S. Szmigiero
On 05.08.2015 16:51, Greg Kroah-Hartman wrote:
 On Wed, Aug 05, 2015 at 02:33:33PM +0200, Maciej S. Szmigiero wrote:
 CIR type serial ports aren't real serial ports.

 This is just a way to prevent legacy 8250 serial
 driver from probing and eventually binding some
 resources.

 Since in current state such ports aren't providing
 any real functionality and it is not possible
 to change their type via setserial/ioctl(TIOCSSERIAL)
 (due to UPF_FIXED_PORT flag set on them)
 it is simpler and cleaner to not register them at all
 with serial core.

 Print a short message in this case so it is known
 to user what has happened.

 This way checks for PORT_8250_CIR in serial port
 callbacks can be removed too, since they won't
 ever be called.

 Signed-off-by: Maciej Szmigiero m...@maciej.szmigiero.name
 ---
 This replaces serial: don't announce CIR serial ports
 submission.

  drivers/tty/serial/8250/8250_core.c |   38 
 +-
  1 files changed, 19 insertions(+), 19 deletions(-)

 diff --git a/drivers/tty/serial/8250/8250_core.c 
 b/drivers/tty/serial/8250/8250_core.c
 index 37fff12..b843b83 100644
 --- a/drivers/tty/serial/8250/8250_core.c
 +++ b/drivers/tty/serial/8250/8250_core.c
 @@ -2129,9 +2129,6 @@ int serial8250_do_startup(struct uart_port *port)
  unsigned char lsr, iir;
  int retval;
  
 -if (port-type == PORT_8250_CIR)
 -return -ENODEV;
 -
  if (!port-fifosize)
  port-fifosize = uart_config[port-type].fifo_size;
  if (!up-tx_loadsz)
 @@ -2858,14 +2855,8 @@ static void serial8250_release_port(struct uart_port 
 *port)
  static int serial8250_request_port(struct uart_port *port)
  {
  struct uart_8250_port *up = up_to_u8250p(port);
 -int ret;
 -
 -if (port-type == PORT_8250_CIR)
 -return -ENODEV;
 -
 -ret = serial8250_request_std_resource(up);
  
 -return ret;
 +return serial8250_request_std_resource(up);
  }
  
  static int fcr_get_rxtrig_bytes(struct uart_8250_port *up)
 @@ -3013,9 +3004,6 @@ static void serial8250_config_port(struct uart_port 
 *port, int flags)
  struct uart_8250_port *up = up_to_u8250p(port);
  int ret;
  
 -if (port-type == PORT_8250_CIR)
 -return;
 -
  /*
   * Find the region that we can probe for.  This in turn
   * tells us whether we can probe for the type of port.
 @@ -3889,13 +3877,25 @@ int serial8250_register_8250_port(struct 
 uart_8250_port *up)
  if (up-dl_write)
  uart-dl_write = up-dl_write;
  
 -if (serial8250_isa_config != NULL)
 -serial8250_isa_config(0, uart-port,
 -uart-capabilities);
 +if (uart-port.type != PORT_8250_CIR) {
 +if (serial8250_isa_config != NULL)
 +serial8250_isa_config(0, uart-port,
 +uart-capabilities);
  
 -ret = uart_add_one_port(serial8250_reg, uart-port);
 -if (ret == 0)
 -ret = uart-port.line;
 +ret = uart_add_one_port(serial8250_reg,
 +uart-port);
 +if (ret == 0)
 +ret = uart-port.line;
 +} else {
 +pr_info(%s%sskipping CIR port at 0x%lx / 0x%llx, IRQ 
 %d\n,
 +uart-port.dev ? dev_name(uart-port.dev) : ,
 +uart-port.dev ? :  : ,
 +uart-port.iobase,
 +(unsigned long long)uart-port.mapbase,
 +uart-port.irq);
 
 dev_info() perhaps?  It provides much of what you are trying to say
 here.

I thought about it, but while currently uart-port.dev is always set
(because these ports are registered by PNP 8250 driver) maybe
one day other sources will also make use of this port type.

Then dev_info() will result in (NULL device *):  prefix.
That's why it is a similar construct as in uart_report_port() to
skip device name altogether in such case.

Best regards,
Maciej Szmigiero

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/6][RESEND] ASoC: fsl_ssi: enable IPG clock during AC'97 reg access

2015-08-05 Thread Maciej S. Szmigiero
IPG clock have to be enabled during AC'97 CODEC register
access in fsl_ssi driver.

Signed-off-by: Maciej Szmigiero m...@maciej.szmigiero.name
---
This is a resend without changes, to keep the whole series
together.

 sound/soc/fsl/fsl_ssi.c |   19 +++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index 484ff20..8185edc 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -1127,10 +1127,17 @@ static void fsl_ssi_ac97_write(struct snd_ac97 *ac97, 
unsigned short reg,
struct regmap *regs = fsl_ac97_data-regs;
unsigned int lreg;
unsigned int lval;
+   int ret;
 
if (reg  0x7f)
return;
 
+   ret = clk_prepare_enable(fsl_ac97_data-clk);
+   if (ret) {
+   pr_err(ac97 write clk_prepare_enable failed: %d\n,
+   ret);
+   return;
+   }
 
lreg = reg   12;
regmap_write(regs, CCSR_SSI_SACADD, lreg);
@@ -1141,6 +1148,8 @@ static void fsl_ssi_ac97_write(struct snd_ac97 *ac97, 
unsigned short reg,
regmap_update_bits(regs, CCSR_SSI_SACNT, CCSR_SSI_SACNT_RDWR_MASK,
CCSR_SSI_SACNT_WR);
udelay(100);
+
+   clk_disable_unprepare(fsl_ac97_data-clk);
 }
 
 static unsigned short fsl_ssi_ac97_read(struct snd_ac97 *ac97,
@@ -1151,6 +1160,14 @@ static unsigned short fsl_ssi_ac97_read(struct snd_ac97 
*ac97,
unsigned short val = -1;
u32 reg_val;
unsigned int lreg;
+   int ret;
+
+   ret = clk_prepare_enable(fsl_ac97_data-clk);
+   if (ret) {
+   pr_err(ac97 read clk_prepare_enable failed: %d\n,
+   ret);
+   return -1;
+   }
 
lreg = (reg  0x7f)   12;
regmap_write(regs, CCSR_SSI_SACADD, lreg);
@@ -1162,6 +1179,8 @@ static unsigned short fsl_ssi_ac97_read(struct snd_ac97 
*ac97,
regmap_read(regs, CCSR_SSI_SACDAT, reg_val);
val = (reg_val  4)  0x;
 
+   clk_disable_unprepare(fsl_ac97_data-clk);
+
return val;
 }
 

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/6][RESEND] ASoC: fsl_ssi: AC'97 DAI driver needs probe method too

2015-08-05 Thread Maciej S. Szmigiero
AC'97 DAI driver struct need the same probe method as
I2S one to setup DMA params in fsl_ssi driver.

Signed-off-by: Maciej Szmigiero m...@maciej.szmigiero.name
---
This is a resend without changes, to keep the whole series
together.

 sound/soc/fsl/fsl_ssi.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index 8185edc..a83b900 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -1101,6 +1101,7 @@ static const struct snd_soc_component_driver 
fsl_ssi_component = {
 
 static struct snd_soc_dai_driver fsl_ssi_ac97_dai = {
.bus_control = true,
+   .probe = fsl_ssi_dai_probe,
.playback = {
.stream_name = AC97 Playback,
.channels_min = 2,

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/6][RESEND] ASoC: fsl_ssi: enable AC'97 asymmetric rates

2015-08-05 Thread Maciej S. Szmigiero
AC'97 bus can support asymmetric playback/capture rates
so enable them in this case in fsl_ssi driver.

Signed-off-by: Maciej Szmigiero m...@maciej.szmigiero.name
---
This is a resend without changes, to keep the whole series
together.

 sound/soc/fsl/fsl_ssi.c |4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index a83b900..7f4f0b9 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -1377,7 +1377,9 @@ static int fsl_ssi_probe(struct platform_device *pdev)
 
/* Are the RX and the TX clocks locked? */
if (!of_find_property(np, fsl,ssi-asynchronous, NULL)) {
-   ssi_private-cpu_dai_drv.symmetric_rates = 1;
+   if (!fsl_ssi_is_ac97(ssi_private))
+   ssi_private-cpu_dai_drv.symmetric_rates = 1;
+
ssi_private-cpu_dai_drv.symmetric_channels = 1;
ssi_private-cpu_dai_drv.symmetric_samplebits = 1;
}

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 4/6][RESEND] ASoC: fsl_ssi: add AC'97 ops setting check and cleanup

2015-08-05 Thread Maciej S. Szmigiero
Check whether setting AC'97 ops succeeded and clean them
on removal so the fsl_ssi driver can be reloaded.

Signed-off-by: Maciej Szmigiero m...@maciej.szmigiero.name
---
This is a resend without changes, to keep the whole series
together.

 sound/soc/fsl/fsl_ssi.c |9 -
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index 7f4f0b9..154bcf6 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -1340,7 +1340,11 @@ static int fsl_ssi_probe(struct platform_device *pdev)
 
fsl_ac97_data = ssi_private;
 
-   snd_soc_set_ac97_ops_of_reset(fsl_ssi_ac97_ops, pdev);
+   ret = snd_soc_set_ac97_ops_of_reset(fsl_ssi_ac97_ops, pdev);
+   if (ret) {
+   dev_err(pdev-dev, could not set AC'97 ops\n);
+   return ret;
+   }
} else {
/* Initialize this copy of the CPU DAI driver structure */
memcpy(ssi_private-cpu_dai_drv, fsl_ssi_dai_template,
@@ -1480,6 +1484,9 @@ static int fsl_ssi_remove(struct platform_device *pdev)
if (ssi_private-soc-imx)
fsl_ssi_imx_clean(pdev, ssi_private);
 
+   if (fsl_ssi_is_ac97(ssi_private))
+   snd_soc_set_ac97_ops(NULL);
+
return 0;
 }
 

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 5/6][RESEND] ASoC: fsl_ssi: instantiate AC'97 CODEC

2015-08-05 Thread Maciej S. Szmigiero
Instantiate AC'97 CODEC in fsl_ssi driver AC'97 mode.

Signed-off-by: Maciej Szmigiero m...@maciej.szmigiero.name
---
This is a resend without changes, to keep the whole series
together.

 sound/soc/fsl/fsl_ssi.c |   21 +
 1 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index 154bcf6..8e5ff5e 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -1460,6 +1460,27 @@ done:
_fsl_ssi_set_dai_fmt(pdev-dev, ssi_private,
 ssi_private-dai_fmt);
 
+   if (fsl_ssi_is_ac97(ssi_private)) {
+   u32 ssi_idx;
+
+   ret = of_property_read_u32(np, cell-index, ssi_idx);
+   if (ret) {
+   dev_err(pdev-dev, cannot get SSI index property\n);
+   goto error_sound_card;
+   }
+
+   ssi_private-pdev =
+   platform_device_register_data(NULL,
+   ac97-codec, ssi_idx, NULL, 0);
+   if (IS_ERR(ssi_private-pdev)) {
+   ret = PTR_ERR(ssi_private-pdev);
+   dev_err(pdev-dev,
+   failed to register AC97 codec platform: %d\n,
+   ret);
+   goto error_sound_card;
+   }
+   }
+
return 0;
 
 error_sound_card:

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 6/6 v2][RESEND] ASoC: fsl_ssi: adjust set DAI format in AC'97 mode

2015-08-05 Thread Maciej S. Szmigiero
Adjust set DAI format function in fsl_ssi driver
so it doesn't fail and clears RXDIR in AC'97 mode.

Signed-off-by: Maciej Szmigiero m...@maciej.szmigiero.name
---
Changes from v1: fix indentation to be consistent with rest
of the driver.

 sound/soc/fsl/fsl_ssi.c |8 +---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index 8e5ff5e..1ba63bd 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -900,14 +900,16 @@ static int _fsl_ssi_set_dai_fmt(struct device *dev,
scr = ~CCSR_SSI_SCR_SYS_CLK_EN;
break;
default:
-   return -EINVAL;
+   if (!fsl_ssi_is_ac97(ssi_private))
+   return -EINVAL;
}
 
stcr |= strcr;
srcr |= strcr;
 
-   if (ssi_private-cpu_dai_drv.symmetric_rates) {
-   /* Need to clear RXDIR when using SYNC mode */
+   if (ssi_private-cpu_dai_drv.symmetric_rates
+   || fsl_ssi_is_ac97(ssi_private)) {
+   /* Need to clear RXDIR when using SYNC or AC97 mode */
srcr = ~CCSR_SSI_SRCR_RXDIR;
scr |= CCSR_SSI_SCR_SYN;
}

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv2] serial: don't register CIR serial ports

2015-08-05 Thread Maciej S. Szmigiero
CIR type serial ports aren't real serial ports.

This is just a way to prevent legacy 8250 serial
driver from probing and eventually binding some
resources.

Since in current state such ports aren't providing
any real functionality and it is not possible
to change their type via setserial/ioctl(TIOCSSERIAL)
(due to UPF_FIXED_PORT flag set on them)
it is simpler and cleaner to not register them at all
with serial core.

Print a short message in this case so it is known
to user what has happened.

This way checks for PORT_8250_CIR in serial port
callbacks can be removed too, since they won't
ever be called.

Signed-off-by: Maciej Szmigiero m...@maciej.szmigiero.name
---
This replaces serial: don't announce CIR serial ports
submission.

Changes from v1: print message using dev_info()

 drivers/tty/serial/8250/8250_core.c |   37 +--
 1 files changed, 18 insertions(+), 19 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_core.c 
b/drivers/tty/serial/8250/8250_core.c
index 37fff12..145b0b37 100644
--- a/drivers/tty/serial/8250/8250_core.c
+++ b/drivers/tty/serial/8250/8250_core.c
@@ -2129,9 +2129,6 @@ int serial8250_do_startup(struct uart_port *port)
unsigned char lsr, iir;
int retval;
 
-   if (port-type == PORT_8250_CIR)
-   return -ENODEV;
-
if (!port-fifosize)
port-fifosize = uart_config[port-type].fifo_size;
if (!up-tx_loadsz)
@@ -2858,14 +2855,8 @@ static void serial8250_release_port(struct uart_port 
*port)
 static int serial8250_request_port(struct uart_port *port)
 {
struct uart_8250_port *up = up_to_u8250p(port);
-   int ret;
-
-   if (port-type == PORT_8250_CIR)
-   return -ENODEV;
-
-   ret = serial8250_request_std_resource(up);
 
-   return ret;
+   return serial8250_request_std_resource(up);
 }
 
 static int fcr_get_rxtrig_bytes(struct uart_8250_port *up)
@@ -3013,9 +3004,6 @@ static void serial8250_config_port(struct uart_port 
*port, int flags)
struct uart_8250_port *up = up_to_u8250p(port);
int ret;
 
-   if (port-type == PORT_8250_CIR)
-   return;
-
/*
 * Find the region that we can probe for.  This in turn
 * tells us whether we can probe for the type of port.
@@ -3889,13 +3877,24 @@ int serial8250_register_8250_port(struct uart_8250_port 
*up)
if (up-dl_write)
uart-dl_write = up-dl_write;
 
-   if (serial8250_isa_config != NULL)
-   serial8250_isa_config(0, uart-port,
-   uart-capabilities);
+   if (uart-port.type != PORT_8250_CIR) {
+   if (serial8250_isa_config != NULL)
+   serial8250_isa_config(0, uart-port,
+   uart-capabilities);
 
-   ret = uart_add_one_port(serial8250_reg, uart-port);
-   if (ret == 0)
-   ret = uart-port.line;
+   ret = uart_add_one_port(serial8250_reg,
+   uart-port);
+   if (ret == 0)
+   ret = uart-port.line;
+   } else {
+   dev_info(uart-port.dev,
+   skipping CIR port at 0x%lx / 0x%llx, IRQ %d\n,
+   uart-port.iobase,
+   (unsigned long long)uart-port.mapbase,
+   uart-port.irq);
+
+   ret = 0;
+   }
}
mutex_unlock(serial_mutex);
 

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] serial: don't announce CIR serial ports

2015-08-04 Thread Maciej S. Szmigiero
Hi Peter,

Thanks for looking into it.

On 04.08.2015 03:46, Peter Hurley wrote:
 Hi Maciej,
 
 On 08/02/2015 05:09 PM, Maciej S. Szmigiero wrote:
 CIR type serial ports aren't real serial ports.
 This is just a way to prevent legacy serial driver
 from probing and eventually binding some resources
 so don't announce them like normal serial ports.
 
 I'd like to keep some form of reporting so that we know the
 port was properly probed; what about extending uart_report_port()
 to including CIR + disabled status?

Currently the printed message looks like this:
00:01: ttyS2 at I/O 0x3e8 (irq = 7, base_baud = 115200) is a CIR port.

I think it would be best to skip a device file name in this case,
since this is how user sees (and uses) a real serial port.
The message would be then:
00:01 at I/O 0x3e8 (irq = 7, base_baud = 115200) is a CIR port.

The dev name will always be present since the only current
source of CIR ports is PNP 8250 driver which sets 
dev pointer uncondtionally.

 Secondly, good catch! Because we should not be trying to
 register a console on this port, nor driving modem signals.
 
 So maybe an early exit after uart_report_port?

All right, I will resubmit updated patch tomorrow.

 Regards,
 Peter Hurley

Best regards,
Maciej Szmigiero
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv3] serial: don't register CIR serial ports

2015-08-15 Thread Maciej S. Szmigiero
CIR type serial ports aren't real serial ports.

This is just a way to prevent legacy 8250 serial
driver from probing and eventually binding some
resources.

Since in current state such ports aren't providing
any real functionality and it is not possible
to change their type via setserial/ioctl(TIOCSSERIAL)
(due to UPF_FIXED_PORT flag set on them)
it is simpler and cleaner to not register them at all
with serial core.

Print a short message in this case so it is known
to user what has happened.

This way checks for PORT_8250_CIR in serial port
callbacks can be removed too, since they won't
ever be called.

Signed-off-by: Maciej Szmigiero m...@maciej.szmigiero.name
---
This replaces serial: don't announce CIR serial ports
submission.

Changes from v1: print message using dev_info().

Changes from v2: added specific code in
serial8250_register_ports() regarding not adding
PORT_8250_CIR-type ports, updated to changes in
tty-testing branch.

 drivers/tty/serial/8250/8250_core.c | 26 --
 drivers/tty/serial/8250/8250_port.c | 14 +-
 2 files changed, 21 insertions(+), 19 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_core.c 
b/drivers/tty/serial/8250/8250_core.c
index cfbb9d7..2308ff8 100644
--- a/drivers/tty/serial/8250/8250_core.c
+++ b/drivers/tty/serial/8250/8250_core.c
@@ -569,6 +569,9 @@ serial8250_register_ports(struct uart_driver *drv, struct 
device *dev)
for (i = 0; i  nr_uarts; i++) {
struct uart_8250_port *up = serial8250_ports[i];
 
+   if (up-port.type == PORT_8250_CIR)
+   continue;
+
if (up-port.dev)
continue;
 
@@ -1027,13 +1030,24 @@ int serial8250_register_8250_port(struct uart_8250_port 
*up)
if (up-dl_write)
uart-dl_write = up-dl_write;
 
-   if (serial8250_isa_config != NULL)
-   serial8250_isa_config(0, uart-port,
-   uart-capabilities);
+   if (uart-port.type != PORT_8250_CIR) {
+   if (serial8250_isa_config != NULL)
+   serial8250_isa_config(0, uart-port,
+   uart-capabilities);
+
+   ret = uart_add_one_port(serial8250_reg,
+   uart-port);
+   if (ret == 0)
+   ret = uart-port.line;
+   } else {
+   dev_info(uart-port.dev,
+   skipping CIR port at 0x%lx / 0x%llx, IRQ %d\n,
+   uart-port.iobase,
+   (unsigned long long)uart-port.mapbase,
+   uart-port.irq);
 
-   ret = uart_add_one_port(serial8250_reg, uart-port);
-   if (ret == 0)
-   ret = uart-port.line;
+   ret = 0;
+   }
}
mutex_unlock(serial_mutex);
 
diff --git a/drivers/tty/serial/8250/8250_port.c 
b/drivers/tty/serial/8250/8250_port.c
index 54e6c8d..138a36f 100644
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
@@ -1799,9 +1799,6 @@ int serial8250_do_startup(struct uart_port *port)
unsigned char lsr, iir;
int retval;
 
-   if (port-type == PORT_8250_CIR)
-   return -ENODEV;
-
if (!port-fifosize)
port-fifosize = uart_config[port-type].fifo_size;
if (!up-tx_loadsz)
@@ -2505,14 +2502,8 @@ static void serial8250_release_port(struct uart_port 
*port)
 static int serial8250_request_port(struct uart_port *port)
 {
struct uart_8250_port *up = up_to_u8250p(port);
-   int ret;
-
-   if (port-type == PORT_8250_CIR)
-   return -ENODEV;
 
-   ret = serial8250_request_std_resource(up);
-
-   return ret;
+   return serial8250_request_std_resource(up);
 }
 
 static int fcr_get_rxtrig_bytes(struct uart_8250_port *up)
@@ -2660,9 +2651,6 @@ static void serial8250_config_port(struct uart_port 
*port, int flags)
struct uart_8250_port *up = up_to_u8250p(port);
int ret;
 
-   if (port-type == PORT_8250_CIR)
-   return;
-
/*
 * Find the region that we can probe for.  This in turn
 * tells us whether we can probe for the type of port.

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/3] of: Add United Radiant Technology Corporation vendor prefix

2015-10-07 Thread Maciej S. Szmigiero
This adds vendor prefix for United Radiant Technology Corporation,
a provider of liquid crystal display technologies.

Signed-off-by: Maciej Szmigiero 
---
 Documentation/devicetree/bindings/vendor-prefixes.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
b/Documentation/devicetree/bindings/vendor-prefixes.txt
index 82d2ac9..01e3cee 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -223,6 +223,7 @@ toshiba Toshiba Corporation
 toumaz Toumaz
 tplink TP-LINK Technologies Co., Ltd.
 truly  Truly Semiconductors Limited
+urtUnited Radiant Technology Corporation
 usiUniversal Scientific Industrial Co., Ltd.
 v3 V3 Semiconductor
 variscite  Variscite Ltd.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/3] of: add URT UMSH-8596MD-xT panel DT bindings

2015-10-07 Thread Maciej S. Szmigiero
This patch adds DT bindings for United Radiant Technology
UMSH-8596MD-xT 7.0" WVGA TFT LCD panels.

Signed-off-by: Maciej Szmigiero 
---
 Documentation/devicetree/bindings/panel/urt,umsh-8596md.txt | 12 
 1 file changed, 12 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/panel/urt,umsh-8596md.txt

diff --git a/Documentation/devicetree/bindings/panel/urt,umsh-8596md.txt 
b/Documentation/devicetree/bindings/panel/urt,umsh-8596md.txt
new file mode 100644
index 000..57c5fa4
--- /dev/null
+++ b/Documentation/devicetree/bindings/panel/urt,umsh-8596md.txt
@@ -0,0 +1,12 @@
+United Radiant Technology UMSH-8596MD-xT 7.0" WVGA TFT LCD panel
+
+Supported are LVDS versions (-11T, -19T) and parallel ones
+(-T, -1T, -7T, -20T).
+
+Required properties:
+- compatible: should be one of:
+  "urt,umsh-8596md-t", "urt,umsh-8596md-1t", "urt,umsh-8596md-7t",
+  "urt,umsh-8596md-11t", "urt,umsh-8596md-19t" or "urt,umsh-8596md-20t".
+
+This binding is compatible with the simple-panel binding, which is specified
+in simple-panel.txt in this directory.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/3] drm: panel-simple: implement URT UMSH-8596MD-xT panel support

2015-10-07 Thread Maciej S. Szmigiero
This patch implements support for United Radiant Technology
UMSH-8596MD-xT 7.0" WVGA TFT LCD panels in DRM panel-simple
driver.

Signed-off-by: Maciej Szmigiero 
---
This replaces "drm: panel-simple: add URT UMSH-8596MD-xT panel support"
submission.

 drivers/gpu/drm/panel/panel-simple.c | 54 
 1 file changed, 54 insertions(+)

diff --git a/drivers/gpu/drm/panel/panel-simple.c 
b/drivers/gpu/drm/panel/panel-simple.c
index f97b73e..44d0deb9 100644
--- a/drivers/gpu/drm/panel/panel-simple.c
+++ b/drivers/gpu/drm/panel/panel-simple.c
@@ -1096,6 +1096,42 @@ static const struct panel_desc shelly_sca07010_bfn_lnn = 
{
.bus_format = MEDIA_BUS_FMT_RGB666_1X18,
 };
 
+static const struct display_timing urt_umsh_8596md_timing = {
+   .pixelclock = { 3326, 3326, 3326 },
+   .hactive = { 800, 800, 800 },
+   .hfront_porch = { 41, 41, 41 },
+   .hback_porch = { 216 - 128, 216 - 128, 216 - 128 },
+   .hsync_len = { 71, 128, 128 },
+   .vactive = { 480, 480, 480 },
+   .vfront_porch = { 10, 10, 10 },
+   .vback_porch = { 35 - 2, 35 - 2, 35 - 2 },
+   .vsync_len = { 2, 2, 2 },
+   .flags = DISPLAY_FLAGS_DE_HIGH | DISPLAY_FLAGS_PIXDATA_NEGEDGE |
+   DISPLAY_FLAGS_HSYNC_LOW | DISPLAY_FLAGS_VSYNC_LOW,
+};
+
+static const struct panel_desc urt_umsh_8596md_lvds = {
+   .timings = _umsh_8596md_timing,
+   .num_timings = 1,
+   .bpc = 6,
+   .size = {
+   .width = 152,
+   .height = 91,
+   },
+   .bus_format = MEDIA_BUS_FMT_RGB666_1X7X3_SPWG,
+};
+
+static const struct panel_desc urt_umsh_8596md_parallel = {
+   .timings = _umsh_8596md_timing,
+   .num_timings = 1,
+   .bpc = 6,
+   .size = {
+   .width = 152,
+   .height = 91,
+   },
+   .bus_format = MEDIA_BUS_FMT_RGB666_1X18,
+};
+
 static const struct of_device_id platform_of_match[] = {
{
.compatible = "ampire,am800480r3tmqwa1h",
@@ -1191,6 +1227,24 @@ static const struct of_device_id platform_of_match[] = {
.compatible = "shelly,sca07010-bfn-lnn",
.data = _sca07010_bfn_lnn,
}, {
+   .compatible = "urt,umsh-8596md-t",
+   .data = _umsh_8596md_parallel,
+   }, {
+   .compatible = "urt,umsh-8596md-1t",
+   .data = _umsh_8596md_parallel,
+   }, {
+   .compatible = "urt,umsh-8596md-7t",
+   .data = _umsh_8596md_parallel,
+   }, {
+   .compatible = "urt,umsh-8596md-11t",
+   .data = _umsh_8596md_lvds,
+   }, {
+   .compatible = "urt,umsh-8596md-19t",
+   .data = _umsh_8596md_lvds,
+   }, {
+   .compatible = "urt,umsh-8596md-20t",
+   .data = _umsh_8596md_parallel,
+   }, {
/* sentinel */
}
 };

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/2] ASoC: fsl-asoc-card: put ASRC OF node in case of unknown device

2015-08-31 Thread Maciej S. Szmigiero
In case of unknown DT compatible device the ASRC OF node
possibly acquired earlier by of_parse_phandle() has
to be put before returning from probe method.

Signed-off-by: Maciej Szmigiero 
---
 sound/soc/fsl/fsl-asoc-card.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/sound/soc/fsl/fsl-asoc-card.c b/sound/soc/fsl/fsl-asoc-card.c
index 5aeb6ed..96f55ae 100644
--- a/sound/soc/fsl/fsl-asoc-card.c
+++ b/sound/soc/fsl/fsl-asoc-card.c
@@ -488,7 +488,8 @@ static int fsl_asoc_card_probe(struct platform_device *pdev)
priv->dai_fmt |= SND_SOC_DAIFMT_CBM_CFM;
} else {
dev_err(>dev, "unknown Device Tree compatible\n");
-   return -EINVAL;
+   ret = -EINVAL;
+   goto asrc_fail;
}
 
/* Common settings for corresponding Freescale CPU DAI driver */
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/2] ASoC: fsl-asoc-card: add AC'97 support

2015-08-31 Thread Maciej S. Szmigiero
Add AC'97 support to fsl-asoc-card using generic
ASoC AC'97 CODEC.

The SSI controller will silently enable any TX
AC'97 slots that have their bits set in SLOTREQ
received from CODEC and then will redirect some
of playback samples there.

That's why it is important to make sure that
any of CODEC playback slots that can pull samples
are set to slots 3/4 (standard PCM playback slots).
Currently, this applies to S/PDIF slots as they
were seen to pull samples sometimes even with
S/PDIF output being disabled.

Signed-off-by: Maciej Szmigiero 
---
 .../devicetree/bindings/sound/fsl-asoc-card.txt|   10 +-
 sound/soc/fsl/fsl-asoc-card.c  |  145 +++
 2 files changed, 120 insertions(+), 35 deletions(-)

diff --git a/Documentation/devicetree/bindings/sound/fsl-asoc-card.txt 
b/Documentation/devicetree/bindings/sound/fsl-asoc-card.txt
index a96774c..ce55c0a 100644
--- a/Documentation/devicetree/bindings/sound/fsl-asoc-card.txt
+++ b/Documentation/devicetree/bindings/sound/fsl-asoc-card.txt
@@ -13,13 +13,15 @@ So having this generic sound card allows all Freescale SoC 
users to benefit
 from the simplification of a new card support and the capability of the wide
 sample rates support through ASRC.
 
-Note: The card is initially designed for those sound cards who use I2S and
-  PCM DAI formats. However, it'll be also possible to support those non
-  I2S/PCM type sound cards, such as S/PDIF audio and HDMI audio, as long
-  as the driver has been properly upgraded.
+Note: The card is initially designed for those sound cards who use AC'97, I2S
+  and PCM DAI formats. However, it'll be also possible to support those non
+  AC'97/I2S/PCM type sound cards, such as S/PDIF audio and HDMI audio, as
+  long as the driver has been properly upgraded.
 
 
 The compatible list for this generic sound card currently:
+ "fsl,imx-audio-ac97"
+
  "fsl,imx-audio-cs42888"
 
  "fsl,imx-audio-wm8962"
diff --git a/sound/soc/fsl/fsl-asoc-card.c b/sound/soc/fsl/fsl-asoc-card.c
index 96f55ae..385a9f8 100644
--- a/sound/soc/fsl/fsl-asoc-card.c
+++ b/sound/soc/fsl/fsl-asoc-card.c
@@ -14,6 +14,9 @@
 #include 
 #include 
 #include 
+#if IS_ENABLED(CONFIG_SND_AC97_CODEC)
+#include 
+#endif
 #include 
 #include 
 
@@ -115,6 +118,11 @@ static const struct snd_soc_dapm_widget 
fsl_asoc_card_dapm_widgets[] = {
SND_SOC_DAPM_MIC("DMIC", NULL),
 };
 
+static bool fsl_asoc_card_is_ac97(struct fsl_asoc_card_priv *priv)
+{
+   return priv->dai_fmt == SND_SOC_DAIFMT_AC97;
+}
+
 static int fsl_asoc_card_hw_params(struct snd_pcm_substream *substream,
   struct snd_pcm_hw_params *params)
 {
@@ -133,7 +141,9 @@ static int fsl_asoc_card_hw_params(struct snd_pcm_substream 
*substream,
 * set_bias_level(), bypass the remaining settings in hw_params().
 * Note: (dai_fmt & CBM_CFM) includes CBM_CFM and CBM_CFS.
 */
-   if (priv->card.set_bias_level && priv->dai_fmt & SND_SOC_DAIFMT_CBM_CFM)
+   if ((priv->card.set_bias_level &&
+priv->dai_fmt & SND_SOC_DAIFMT_CBM_CFM) ||
+   fsl_asoc_card_is_ac97(priv))
return 0;
 
/* Specific configurations of DAIs starts from here */
@@ -300,7 +310,7 @@ static int fsl_asoc_card_audmux_init(struct device_node *np,
ext_port--;
 
/*
-* Use asynchronous mode (6 wires) for all cases.
+* Use asynchronous mode (6 wires) for all cases except AC97.
 * If only 4 wires are needed, just set SSI into
 * synchronous mode and enable 4 PADs in IOMUX.
 */
@@ -346,15 +356,30 @@ static int fsl_asoc_card_audmux_init(struct device_node 
*np,
   IMX_AUDMUX_V2_PTCR_TCLKDIR;
break;
default:
-   return -EINVAL;
+   if (!fsl_asoc_card_is_ac97(priv))
+   return -EINVAL;
+   }
+
+   if (fsl_asoc_card_is_ac97(priv)) {
+   int_ptcr = IMX_AUDMUX_V2_PTCR_SYN |
+  IMX_AUDMUX_V2_PTCR_TCSEL(ext_port) |
+  IMX_AUDMUX_V2_PTCR_TCLKDIR;
+   ext_ptcr = IMX_AUDMUX_V2_PTCR_SYN |
+  IMX_AUDMUX_V2_PTCR_TFSEL(int_port) |
+  IMX_AUDMUX_V2_PTCR_TFSDIR;
}
 
/* Asynchronous mode can not be set along with RCLKDIR */
-   ret = imx_audmux_v2_configure_port(int_port, 0,
-  IMX_AUDMUX_V2_PDCR_RXDSEL(ext_port));
-   if (ret) {
-   dev_err(dev, "audmux internal port setup failed\n");
-   return ret;
+   if (!fsl_asoc_card_is_ac97(priv)) {
+   unsigned int pdcr =
+   IMX_AUDMUX_V2_PDCR_RXDSEL(ext_port);
+
+   ret = imx_audmux_v2_configure_port(int_port, 0,
+  pdcr);
+   if (ret) {
+   

[PATCH] cfg80211: regulatory: restore proper user alpha2

2015-09-02 Thread Maciej S. Szmigiero
restore_regulatory_settings() should restore alpha2
as computed in restore_alpha2(), not raw user_alpha2 to
behave as described in the comment just above that code.

This fixes endless loop of calling CRDA for "00" and "97"
countries after resume from suspend on my laptop.

Looks like others had the same problem, too:
http://ath9k-devel.ath9k.narkive.com/knY5W6St/ath9k-and-crda-messages-in-logs
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/899335
https://forum.porteus.org/viewtopic.php?t=4975=36436
https://forums.opensuse.org/showthread.php/
483356-Authentication-Regulatory-Domain-issues-ath5k-12-2

Signed-off-by: Maciej Szmigiero 
---
 net/wireless/reg.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 70aef72..7258246 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -2625,7 +2625,7 @@ static void restore_regulatory_settings(bool reset_user)
 * settings, user regulatory settings takes precedence.
 */
if (is_an_alpha2(alpha2))
-   regulatory_hint_user(user_alpha2, NL80211_USER_REG_HINT_USER);
+   regulatory_hint_user(alpha2, NL80211_USER_REG_HINT_USER);
 
spin_lock(_requests_lock);
list_splice_tail_init(_reg_req_list, _requests_list);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] net: fec: normalize return value of pm_runtime_get_sync() in MDIO write

2015-09-03 Thread Maciej S. Szmigiero
If fec MDIO write method succeeds its return value comes from
call to pm_runtime_get_sync().
But pm_runtime_get_sync() can also return 1.

In case of Micrel KSZ9031 PHY this value will then
be returned along the call chain of phy_write() ->
ksz9031_extended_write() -> ksz9031_center_flp_timing() ->
ksz9031_config_init() -> phy_init_hw() -> phy_attach_direct() ->
phy_connect_direct().

Then phy_connect() will cast it into a pointer using ERR_PTR(),
which then fec_enet_mii_probe() will try to dereference
resulting in an oops.

Fix it by normalizing return value of pm_runtime_get_sync()
to be zero if positive in MDIO write method.

Signed-off-by: Maciej Szmigiero 
---
 drivers/net/ethernet/freescale/fec_main.c |4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fec_main.c 
b/drivers/net/ethernet/freescale/fec_main.c
index 91925e3..6cc3340 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -1816,11 +1816,13 @@ static int fec_enet_mdio_write(struct mii_bus *bus, int 
mii_id, int regnum,
struct fec_enet_private *fep = bus->priv;
struct device *dev = >pdev->dev;
unsigned long time_left;
-   int ret = 0;
+   int ret;
 
ret = pm_runtime_get_sync(dev);
if (ret < 0)
return ret;
+   else
+   ret = 0;
 
fep->mii_timeout = 0;
reinit_completion(>mdio_done);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH][RESEND] drm: panel-simple: add URT UMSH-8596MD-xT panel support

2015-09-01 Thread Maciej S. Szmigiero
This patch adds support for United Radiant Technology
UMSH-8596MD-xT 7.0" WVGA TFT LCD panels
(both LVDS and parallel versions) to DRM
panel-simple driver.

Signed-off-by: Maciej Szmigiero 
---
This is a resend without changes.

diff --git a/Documentation/devicetree/bindings/panel/urt,umsh-8596md.txt 
b/Documentation/devicetree/bindings/panel/urt,umsh-8596md.txt
new file mode 100644
index 000..2990e6b
--- /dev/null
+++ b/Documentation/devicetree/bindings/panel/urt,umsh-8596md.txt
@@ -0,0 +1,11 @@
+United Radiant Technology UMSH-8596MD-xT 7.0" WVGA TFT LCD panel
+
+Supported are LVDS versions (-11T, -19T) and parallel ones
+(-T, -1T, -7T, -20T).
+
+Required properties:
+- compatible: should be "urt,umsh-8596md-lvds" for LVDS versions,
+  "urt,umsh-8596md-parallel" for parallel ones.
+
+This binding is compatible with the simple-panel binding, which is specified
+in simple-panel.txt in this directory.
diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
b/Documentation/devicetree/bindings/vendor-prefixes.txt
index 66a33ae..234ce41 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -213,6 +213,7 @@ toshiba Toshiba Corporation
 toumaz Toumaz
 tplink TP-LINK Technologies Co., Ltd.
 truly  Truly Semiconductors Limited
+urtUnited Radiant Technology Corporation
 usiUniversal Scientific Industrial Co., Ltd.
 v3 V3 Semiconductor
 variscite  Variscite Ltd.
diff --git a/drivers/gpu/drm/panel/panel-simple.c 
b/drivers/gpu/drm/panel/panel-simple.c
index f94201b..be47fd7 100644
--- a/drivers/gpu/drm/panel/panel-simple.c
+++ b/drivers/gpu/drm/panel/panel-simple.c
@@ -1036,6 +1036,42 @@ static const struct panel_desc shelly_sca07010_bfn_lnn = 
{
.bus_format = MEDIA_BUS_FMT_RGB666_1X18,
 };
 
+static const struct display_timing urt_umsh_8596md_timing = {
+   .pixelclock = { 3326, 3326, 3326 },
+   .hactive = { 800, 800, 800 },
+   .hfront_porch = { 41, 41, 41 },
+   .hback_porch = { 216 - 128, 216 - 128, 216 - 128 },
+   .hsync_len = { 71, 128, 128 },
+   .vactive = { 480, 480, 480 },
+   .vfront_porch = { 10, 10, 10 },
+   .vback_porch = { 35 - 2, 35 - 2, 35 - 2 },
+   .vsync_len = { 2, 2, 2 },
+   .flags = DISPLAY_FLAGS_DE_HIGH | DISPLAY_FLAGS_PIXDATA_NEGEDGE |
+   DISPLAY_FLAGS_HSYNC_LOW | DISPLAY_FLAGS_VSYNC_LOW,
+};
+
+static const struct panel_desc urt_umsh_8596md_lvds = {
+   .timings = _umsh_8596md_timing,
+   .num_timings = 1,
+   .bpc = 6,
+   .size = {
+   .width = 152,
+   .height = 91,
+   },
+   .bus_format = MEDIA_BUS_FMT_RGB666_1X7X3_SPWG,
+};
+
+static const struct panel_desc urt_umsh_8596md_parallel = {
+   .timings = _umsh_8596md_timing,
+   .num_timings = 1,
+   .bpc = 6,
+   .size = {
+   .width = 152,
+   .height = 91,
+   },
+   .bus_format = MEDIA_BUS_FMT_RGB666_1X18,
+};
+
 static const struct of_device_id platform_of_match[] = {
{
.compatible = "ampire,am800480r3tmqwa1h",
@@ -1125,6 +1161,12 @@ static const struct of_device_id platform_of_match[] = {
.compatible = "shelly,sca07010-bfn-lnn",
.data = _sca07010_bfn_lnn,
}, {
+   .compatible = "urt,umsh-8596md-lvds",
+   .data = _umsh_8596md_lvds,
+   }, {
+   .compatible = "urt,umsh-8596md-parallel",
+   .data = _umsh_8596md_parallel,
+   }, {
/* sentinel */
}
 };
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH][RESEND] drm: panel-simple: add URT UMSH-8596MD-xT panel support

2015-10-04 Thread Maciej S. Szmigiero
Hi Emil,

Thanks for your response,

On 04.10.2015 12:43, Emil Velikov wrote:
> Hi Maciej,
> 
> On 2 October 2015 at 22:40, Maciej S. Szmigiero
> <m...@maciej.szmigiero.name> wrote:
>> Anybody here?
>>
>> I've already submitted this patch two times but received no response...
>>
> Seems that the maintainer (Thierry) isn't Cc'ed.

Yes, he was Cc'ed - see for example https://patchwork.ozlabs.org/patch/512858/ .

> You might want to
> split the DT binding and vendor prefix to separate patches.

Do you mean to first submit new vendor prefix then panel patch with docs?
Or even docs separately?

> -Emil
> 

Best regards,
Maciej

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH][RESEND] drm: panel-simple: add URT UMSH-8596MD-xT panel support

2015-10-02 Thread Maciej S. Szmigiero
Anybody here?

I've already submitted this patch two times but received no response...

Maciej Szmigiero

On 01.09.2015 15:50, Maciej S. Szmigiero wrote:
> This patch adds support for United Radiant Technology
> UMSH-8596MD-xT 7.0" WVGA TFT LCD panels
> (both LVDS and parallel versions) to DRM
> panel-simple driver.
> 
> Signed-off-by: Maciej Szmigiero <m...@maciej.szmigiero.name>
> ---
> This is a resend without changes.
> 
> diff --git a/Documentation/devicetree/bindings/panel/urt,umsh-8596md.txt 
> b/Documentation/devicetree/bindings/panel/urt,umsh-8596md.txt
> new file mode 100644
> index 000..2990e6b
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/panel/urt,umsh-8596md.txt
> @@ -0,0 +1,11 @@
> +United Radiant Technology UMSH-8596MD-xT 7.0" WVGA TFT LCD panel
> +
> +Supported are LVDS versions (-11T, -19T) and parallel ones
> +(-T, -1T, -7T, -20T).
> +
> +Required properties:
> +- compatible: should be "urt,umsh-8596md-lvds" for LVDS versions,
> +  "urt,umsh-8596md-parallel" for parallel ones.
> +
> +This binding is compatible with the simple-panel binding, which is specified
> +in simple-panel.txt in this directory.
> diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
> b/Documentation/devicetree/bindings/vendor-prefixes.txt
> index 66a33ae..234ce41 100644
> --- a/Documentation/devicetree/bindings/vendor-prefixes.txt
> +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
> @@ -213,6 +213,7 @@ toshiba   Toshiba Corporation
>  toumaz   Toumaz
>  tplink   TP-LINK Technologies Co., Ltd.
>  trulyTruly Semiconductors Limited
> +urt  United Radiant Technology Corporation
>  usi  Universal Scientific Industrial Co., Ltd.
>  v3   V3 Semiconductor
>  varisciteVariscite Ltd.
> diff --git a/drivers/gpu/drm/panel/panel-simple.c 
> b/drivers/gpu/drm/panel/panel-simple.c
> index f94201b..be47fd7 100644
> --- a/drivers/gpu/drm/panel/panel-simple.c
> +++ b/drivers/gpu/drm/panel/panel-simple.c
> @@ -1036,6 +1036,42 @@ static const struct panel_desc shelly_sca07010_bfn_lnn 
> = {
>   .bus_format = MEDIA_BUS_FMT_RGB666_1X18,
>  };
>  
> +static const struct display_timing urt_umsh_8596md_timing = {
> + .pixelclock = { 3326, 3326, 3326 },
> + .hactive = { 800, 800, 800 },
> + .hfront_porch = { 41, 41, 41 },
> + .hback_porch = { 216 - 128, 216 - 128, 216 - 128 },
> + .hsync_len = { 71, 128, 128 },
> + .vactive = { 480, 480, 480 },
> + .vfront_porch = { 10, 10, 10 },
> + .vback_porch = { 35 - 2, 35 - 2, 35 - 2 },
> + .vsync_len = { 2, 2, 2 },
> + .flags = DISPLAY_FLAGS_DE_HIGH | DISPLAY_FLAGS_PIXDATA_NEGEDGE |
> + DISPLAY_FLAGS_HSYNC_LOW | DISPLAY_FLAGS_VSYNC_LOW,
> +};
> +
> +static const struct panel_desc urt_umsh_8596md_lvds = {
> + .timings = _umsh_8596md_timing,
> + .num_timings = 1,
> + .bpc = 6,
> + .size = {
> + .width = 152,
> + .height = 91,
> + },
> + .bus_format = MEDIA_BUS_FMT_RGB666_1X7X3_SPWG,
> +};
> +
> +static const struct panel_desc urt_umsh_8596md_parallel = {
> + .timings = _umsh_8596md_timing,
> + .num_timings = 1,
> + .bpc = 6,
> + .size = {
> + .width = 152,
> + .height = 91,
> + },
> + .bus_format = MEDIA_BUS_FMT_RGB666_1X18,
> +};
> +
>  static const struct of_device_id platform_of_match[] = {
>   {
>   .compatible = "ampire,am800480r3tmqwa1h",
> @@ -1125,6 +1161,12 @@ static const struct of_device_id platform_of_match[] = 
> {
>   .compatible = "shelly,sca07010-bfn-lnn",
>   .data = _sca07010_bfn_lnn,
>   }, {
> + .compatible = "urt,umsh-8596md-lvds",
> + .data = _umsh_8596md_lvds,
> + }, {
> + .compatible = "urt,umsh-8596md-parallel",
> + .data = _umsh_8596md_parallel,
> + }, {
>   /* sentinel */
>   }
>  };
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv3][RESEND] serial: don't register CIR serial ports

2015-09-27 Thread Maciej S. Szmigiero
CIR type serial ports aren't real serial ports.

This is just a way to prevent legacy 8250 serial
driver from probing and eventually binding some
resources.

Since in current state such ports aren't providing
any real functionality and it is not possible
to change their type via setserial/ioctl(TIOCSSERIAL)
(due to UPF_FIXED_PORT flag set on them)
it is simpler and cleaner to not register them at all
with serial core.

Print a short message in this case so it is known
to user what has happened.

This way checks for PORT_8250_CIR in serial port
callbacks can be removed too, since they won't
ever be called.

Signed-off-by: Maciej Szmigiero 
---
This replaces "serial: don't announce CIR serial ports"
submission.

Changes from v1: print message using dev_info().

Changes from v2: added specific code in
serial8250_register_ports() regarding not adding
PORT_8250_CIR-type ports, updated to changes in
tty-testing branch.

This is a resend of v3 without functional changes,
just rebased to current tty-next.

 drivers/tty/serial/8250/8250_core.c | 26 --
 drivers/tty/serial/8250/8250_port.c | 14 +-
 2 files changed, 21 insertions(+), 19 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_core.c 
b/drivers/tty/serial/8250/8250_core.c
index 271d121..3912646 100644
--- a/drivers/tty/serial/8250/8250_core.c
+++ b/drivers/tty/serial/8250/8250_core.c
@@ -569,6 +569,9 @@ serial8250_register_ports(struct uart_driver *drv, struct 
device *dev)
for (i = 0; i < nr_uarts; i++) {
struct uart_8250_port *up = _ports[i];
 
+   if (up->port.type == PORT_8250_CIR)
+   continue;
+
if (up->port.dev)
continue;
 
@@ -1027,13 +1030,24 @@ int serial8250_register_8250_port(struct uart_8250_port 
*up)
if (up->dl_write)
uart->dl_write = up->dl_write;
 
-   if (serial8250_isa_config != NULL)
-   serial8250_isa_config(0, >port,
-   >capabilities);
+   if (uart->port.type != PORT_8250_CIR) {
+   if (serial8250_isa_config != NULL)
+   serial8250_isa_config(0, >port,
+   >capabilities);
+
+   ret = uart_add_one_port(_reg,
+   >port);
+   if (ret == 0)
+   ret = uart->port.line;
+   } else {
+   dev_info(uart->port.dev,
+   "skipping CIR port at 0x%lx / 0x%llx, IRQ %d\n",
+   uart->port.iobase,
+   (unsigned long long)uart->port.mapbase,
+   uart->port.irq);
 
-   ret = uart_add_one_port(_reg, >port);
-   if (ret == 0)
-   ret = uart->port.line;
+   ret = 0;
+   }
}
mutex_unlock(_mutex);
 
diff --git a/drivers/tty/serial/8250/8250_port.c 
b/drivers/tty/serial/8250/8250_port.c
index 54e6c8d..138a36f 100644
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
@@ -1799,9 +1799,6 @@ int serial8250_do_startup(struct uart_port *port)
unsigned char lsr, iir;
int retval;
 
-   if (port->type == PORT_8250_CIR)
-   return -ENODEV;
-
if (!port->fifosize)
port->fifosize = uart_config[port->type].fifo_size;
if (!up->tx_loadsz)
@@ -2505,14 +2502,8 @@ static void serial8250_release_port(struct uart_port 
*port)
 static int serial8250_request_port(struct uart_port *port)
 {
struct uart_8250_port *up = up_to_u8250p(port);
-   int ret;
-
-   if (port->type == PORT_8250_CIR)
-   return -ENODEV;
 
-   ret = serial8250_request_std_resource(up);
-
-   return ret;
+   return serial8250_request_std_resource(up);
 }
 
 static int fcr_get_rxtrig_bytes(struct uart_8250_port *up)
@@ -2660,9 +2651,6 @@ static void serial8250_config_port(struct uart_port 
*port, int flags)
struct uart_8250_port *up = up_to_u8250p(port);
int ret;
 
-   if (port->type == PORT_8250_CIR)
-   return;
-
/*
 * Find the region that we can probe for.  This in turn
 * tells us whether we can probe for the type of port.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2] ASoC: fsl-asoc-card: add AC'97 support

2015-09-18 Thread Maciej S. Szmigiero
Add AC'97 support to fsl-asoc-card using generic
ASoC AC'97 CODEC.

The SSI controller will silently enable any TX
AC'97 slots that have their bits set in SLOTREQ
received from CODEC and then will redirect some
of playback samples there.

That's why it is important to make sure that
any of CODEC playback slots that can pull samples
are set to slots 3/4 (standard PCM playback slots).
Currently, this applies to S/PDIF slots as they
were seen to pull samples sometimes even with
S/PDIF output being disabled.

Signed-off-by: Maciej Szmigiero 
---
Changes from v1: don't use of_find_device_by_node() to
get pointer to I2S/PCM CODEC device as this only matches
platform bus devices while I2S/PCM CODECs supported by
this driver sit on I2C bus.

 .../devicetree/bindings/sound/fsl-asoc-card.txt|  10 +-
 sound/soc/fsl/fsl-asoc-card.c  | 140 -
 2 files changed, 116 insertions(+), 34 deletions(-)

diff --git a/Documentation/devicetree/bindings/sound/fsl-asoc-card.txt 
b/Documentation/devicetree/bindings/sound/fsl-asoc-card.txt
index a96774c..ce55c0a 100644
--- a/Documentation/devicetree/bindings/sound/fsl-asoc-card.txt
+++ b/Documentation/devicetree/bindings/sound/fsl-asoc-card.txt
@@ -13,13 +13,15 @@ So having this generic sound card allows all Freescale SoC 
users to benefit
 from the simplification of a new card support and the capability of the wide
 sample rates support through ASRC.
 
-Note: The card is initially designed for those sound cards who use I2S and
-  PCM DAI formats. However, it'll be also possible to support those non
-  I2S/PCM type sound cards, such as S/PDIF audio and HDMI audio, as long
-  as the driver has been properly upgraded.
+Note: The card is initially designed for those sound cards who use AC'97, I2S
+  and PCM DAI formats. However, it'll be also possible to support those non
+  AC'97/I2S/PCM type sound cards, such as S/PDIF audio and HDMI audio, as
+  long as the driver has been properly upgraded.
 
 
 The compatible list for this generic sound card currently:
+ "fsl,imx-audio-ac97"
+
  "fsl,imx-audio-cs42888"
 
  "fsl,imx-audio-wm8962"
diff --git a/sound/soc/fsl/fsl-asoc-card.c b/sound/soc/fsl/fsl-asoc-card.c
index 0901d5e..1b05d1c 100644
--- a/sound/soc/fsl/fsl-asoc-card.c
+++ b/sound/soc/fsl/fsl-asoc-card.c
@@ -14,6 +14,9 @@
 #include 
 #include 
 #include 
+#if IS_ENABLED(CONFIG_SND_AC97_CODEC)
+#include 
+#endif
 #include 
 #include 
 
@@ -115,6 +118,11 @@ static const struct snd_soc_dapm_widget 
fsl_asoc_card_dapm_widgets[] = {
SND_SOC_DAPM_MIC("DMIC", NULL),
 };
 
+static bool fsl_asoc_card_is_ac97(struct fsl_asoc_card_priv *priv)
+{
+   return priv->dai_fmt == SND_SOC_DAIFMT_AC97;
+}
+
 static int fsl_asoc_card_hw_params(struct snd_pcm_substream *substream,
   struct snd_pcm_hw_params *params)
 {
@@ -133,7 +141,9 @@ static int fsl_asoc_card_hw_params(struct snd_pcm_substream 
*substream,
 * set_bias_level(), bypass the remaining settings in hw_params().
 * Note: (dai_fmt & CBM_CFM) includes CBM_CFM and CBM_CFS.
 */
-   if (priv->card.set_bias_level && priv->dai_fmt & SND_SOC_DAIFMT_CBM_CFM)
+   if ((priv->card.set_bias_level &&
+priv->dai_fmt & SND_SOC_DAIFMT_CBM_CFM) ||
+   fsl_asoc_card_is_ac97(priv))
return 0;
 
/* Specific configurations of DAIs starts from here */
@@ -300,7 +310,7 @@ static int fsl_asoc_card_audmux_init(struct device_node *np,
ext_port--;
 
/*
-* Use asynchronous mode (6 wires) for all cases.
+* Use asynchronous mode (6 wires) for all cases except AC97.
 * If only 4 wires are needed, just set SSI into
 * synchronous mode and enable 4 PADs in IOMUX.
 */
@@ -346,15 +356,30 @@ static int fsl_asoc_card_audmux_init(struct device_node 
*np,
   IMX_AUDMUX_V2_PTCR_TCLKDIR;
break;
default:
-   return -EINVAL;
+   if (!fsl_asoc_card_is_ac97(priv))
+   return -EINVAL;
+   }
+
+   if (fsl_asoc_card_is_ac97(priv)) {
+   int_ptcr = IMX_AUDMUX_V2_PTCR_SYN |
+  IMX_AUDMUX_V2_PTCR_TCSEL(ext_port) |
+  IMX_AUDMUX_V2_PTCR_TCLKDIR;
+   ext_ptcr = IMX_AUDMUX_V2_PTCR_SYN |
+  IMX_AUDMUX_V2_PTCR_TFSEL(int_port) |
+  IMX_AUDMUX_V2_PTCR_TFSDIR;
}
 
/* Asynchronous mode can not be set along with RCLKDIR */
-   ret = imx_audmux_v2_configure_port(int_port, 0,
-  IMX_AUDMUX_V2_PDCR_RXDSEL(ext_port));
-   if (ret) {
-   dev_err(dev, "audmux internal port setup failed\n");
-   return ret;
+   if (!fsl_asoc_card_is_ac97(priv)) {
+   unsigned int pdcr =
+   

Re: [PATCH][RESEND] drm: panel-simple: add URT UMSH-8596MD-xT panel support

2015-10-05 Thread Maciej S. Szmigiero
Hi Thierry,

On 05.10.2015 13:01, Thierry Reding wrote:
>> On 01.09.2015 15:50, Maciej S. Szmigiero wrote:
>>> This patch adds support for United Radiant Technology
>>> UMSH-8596MD-xT 7.0" WVGA TFT LCD panels
>>> (both LVDS and parallel versions) to DRM
>>> panel-simple driver.
>>>
>>> Signed-off-by: Maciej Szmigiero <m...@maciej.szmigiero.name>
>>> ---
>>> This is a resend without changes.
>>>
>>> diff --git a/Documentation/devicetree/bindings/panel/urt,umsh-8596md.txt 
>>> b/Documentation/devicetree/bindings/panel/urt,umsh-8596md.txt
>>> new file mode 100644
>>> index 000..2990e6b
>>> --- /dev/null
>>> +++ b/Documentation/devicetree/bindings/panel/urt,umsh-8596md.txt
>>> @@ -0,0 +1,11 @@
>>> +United Radiant Technology UMSH-8596MD-xT 7.0" WVGA TFT LCD panel
>>> +
>>> +Supported are LVDS versions (-11T, -19T) and parallel ones
>>> +(-T, -1T, -7T, -20T).
> 
> Please don't use this kind of wildcard compatible values. If these are
> different models then each of them deserves a separate compatible
> string.

The differences between these revisions are like different maximum backlight
luminance or presence / absence of touch panel.

None of this changes panel timings - should they be split into different
compatible values anyway?

>>> You might want to
>>> split the DT binding and vendor prefix to separate patches.
>>
>> Do you mean to first submit new vendor prefix then panel patch with docs?
>> Or even docs separately?
> 
> This should be three patches: the vendor prefix is usually a separate
> patch and needs an Acked-by from one of the device tree bindings
> maintainers. The binding itself should also be a separate patch and the
> driver changes should come last.

I will split the patch and first submit DT binding docs.

> Thierry

Best regards,
Maciej

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/3] ASoC: fsl_ssi: mark SACNT register volatile

2015-12-20 Thread Maciej S. Szmigiero
SACNT register should be marked volatile since
its WR and RD bits are cleared by SSI after
completing the relevant operation.
This unbreaks AC'97 register access.

Fixes: 05cf237972fe ("ASoC: fsl_ssi: Add driver suspend and resume to support 
MEGA Fast")

Signed-off-by: Maciej S. Szmigiero <m...@maciej.szmigiero.name>
---
 sound/soc/fsl/fsl_ssi.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index e3abad5f980a..cc22354d7758 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -146,6 +146,7 @@ static bool fsl_ssi_volatile_reg(struct device *dev, 
unsigned int reg)
case CCSR_SSI_SRX1:
case CCSR_SSI_SISR:
case CCSR_SSI_SFCSR:
+   case CCSR_SSI_SACNT:
case CCSR_SSI_SACADD:
case CCSR_SSI_SACDAT:
case CCSR_SSI_SATAG:
@@ -239,8 +240,9 @@ struct fsl_ssi_private {
unsigned int baudclk_streams;
unsigned int bitclk_freq;
 
-   /*regcache for SFCSR*/
+   /* regcache for volatile regs */
u32 regcache_sfcsr;
+   u32 regcache_sacnt;
 
/* DMA params */
struct snd_dmaengine_dai_dma_data dma_params_tx;
@@ -1587,6 +1589,8 @@ static int fsl_ssi_suspend(struct device *dev)
 
regmap_read(regs, CCSR_SSI_SFCSR,
_private->regcache_sfcsr);
+   regmap_read(regs, CCSR_SSI_SACNT,
+   _private->regcache_sacnt);
 
regcache_cache_only(regs, true);
regcache_mark_dirty(regs);
@@ -1605,6 +1609,8 @@ static int fsl_ssi_resume(struct device *dev)
CCSR_SSI_SFCSR_RFWM1_MASK | CCSR_SSI_SFCSR_TFWM1_MASK |
CCSR_SSI_SFCSR_RFWM0_MASK | CCSR_SSI_SFCSR_TFWM0_MASK,
ssi_private->regcache_sfcsr);
+   regmap_write(regs, CCSR_SSI_SACNT,
+   ssi_private->regcache_sacnt);
 
return regcache_sync(regs);
 }
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/3] ASoC: fsl_ssi: mark some registers precious

2015-12-20 Thread Maciej S. Szmigiero
Mark some registers precious since their
reads have side effects (like clearing flags).

Signed-off-by: Maciej S. Szmigiero <m...@maciej.szmigiero.name>
---
 sound/soc/fsl/fsl_ssi.c | 16 
 1 file changed, 16 insertions(+)

diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index cc22354d7758..40dfd8a36484 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -157,6 +157,21 @@ static bool fsl_ssi_volatile_reg(struct device *dev, 
unsigned int reg)
}
 }
 
+static bool fsl_ssi_precious_reg(struct device *dev, unsigned int reg)
+{
+   switch (reg) {
+   case CCSR_SSI_SRX0:
+   case CCSR_SSI_SRX1:
+   case CCSR_SSI_SISR:
+   case CCSR_SSI_SACADD:
+   case CCSR_SSI_SACDAT:
+   case CCSR_SSI_SATAG:
+   return true;
+   default:
+   return false;
+   }
+}
+
 static bool fsl_ssi_writeable_reg(struct device *dev, unsigned int reg)
 {
switch (reg) {
@@ -179,6 +194,7 @@ static const struct regmap_config fsl_ssi_regconfig = {
.num_reg_defaults = ARRAY_SIZE(fsl_ssi_reg_defaults),
.readable_reg = fsl_ssi_readable_reg,
.volatile_reg = fsl_ssi_volatile_reg,
+   .precious_reg = fsl_ssi_precious_reg,
.writeable_reg = fsl_ssi_writeable_reg,
.cache_type = REGCACHE_RBTREE,
 };

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/3] ASoC: fsl_ssi: remove register defaults

2015-12-20 Thread Maciej S. Szmigiero
There is no guarantee that on fsl_ssi module load
SSI registers will have their power-on-reset values.

In fact, if the driver is reloaded the values in
registers will be whatever they were set to previously.

This fixes hard lockup on fsl_ssi module reload,
at least in AC'97 mode.

Fixes: 05cf237972fe ("ASoC: fsl_ssi: Add driver suspend and resume to support 
MEGA Fast")

Signed-off-by: Maciej S. Szmigiero <m...@maciej.szmigiero.name>
---
 sound/soc/fsl/fsl_ssi.c | 16 
 1 file changed, 16 deletions(-)

diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index 40dfd8a36484..f6ef7d64acb3 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -112,20 +112,6 @@ struct fsl_ssi_rxtx_reg_val {
struct fsl_ssi_reg_val tx;
 };
 
-static const struct reg_default fsl_ssi_reg_defaults[] = {
-   {CCSR_SSI_SCR, 0x},
-   {CCSR_SSI_SIER,0x3003},
-   {CCSR_SSI_STCR,0x0200},
-   {CCSR_SSI_SRCR,0x0200},
-   {CCSR_SSI_STCCR,   0x0004},
-   {CCSR_SSI_SRCCR,   0x0004},
-   {CCSR_SSI_SACNT,   0x},
-   {CCSR_SSI_STMSK,   0x},
-   {CCSR_SSI_SRMSK,   0x},
-   {CCSR_SSI_SACCEN,  0x},
-   {CCSR_SSI_SACCDIS, 0x},
-};
-
 static bool fsl_ssi_readable_reg(struct device *dev, unsigned int reg)
 {
switch (reg) {
@@ -190,8 +176,6 @@ static const struct regmap_config fsl_ssi_regconfig = {
.val_bits = 32,
.reg_stride = 4,
.val_format_endian = REGMAP_ENDIAN_NATIVE,
-   .reg_defaults = fsl_ssi_reg_defaults,
-   .num_reg_defaults = ARRAY_SIZE(fsl_ssi_reg_defaults),
.readable_reg = fsl_ssi_readable_reg,
.volatile_reg = fsl_ssi_volatile_reg,
.precious_reg = fsl_ssi_precious_reg,

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] ASoC: fsl-asoc-card: use different route map for AC'97 mode

2015-12-20 Thread Maciej S. Szmigiero
fsl_ssi uses different stream names ("AC97 Playback" / "AC97 Capture")
in AC'97 mode so in this case fsl-asoc-card route map should
also be using them.

Signed-off-by: Maciej S. Szmigiero <m...@maciej.szmigiero.name>
---
 sound/soc/fsl/fsl-asoc-card.c | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/sound/soc/fsl/fsl-asoc-card.c b/sound/soc/fsl/fsl-asoc-card.c
index c63d89da51f1..562b3bd22d9a 100644
--- a/sound/soc/fsl/fsl-asoc-card.c
+++ b/sound/soc/fsl/fsl-asoc-card.c
@@ -107,6 +107,13 @@ static const struct snd_soc_dapm_route audio_map[] = {
{"CPU-Capture",  NULL, "Capture"},
 };
 
+static const struct snd_soc_dapm_route audio_map_ac97[] = {
+   {"AC97 Playback",  NULL, "ASRC-Playback"},
+   {"Playback",  NULL, "AC97 Playback"},
+   {"ASRC-Capture",  NULL, "AC97 Capture"},
+   {"AC97 Capture",  NULL, "Capture"},
+};
+
 /* Add all possible widgets into here without being redundant */
 static const struct snd_soc_dapm_widget fsl_asoc_card_dapm_widgets[] = {
SND_SOC_DAPM_LINE("Line Out Jack", NULL),
@@ -579,7 +586,8 @@ static int fsl_asoc_card_probe(struct platform_device *pdev)
priv->card.dev = >dev;
priv->card.name = priv->name;
priv->card.dai_link = priv->dai_link;
-   priv->card.dapm_routes = audio_map;
+   priv->card.dapm_routes = fsl_asoc_card_is_ac97(priv) ?
+audio_map_ac97 : audio_map;
priv->card.late_probe = fsl_asoc_card_late_probe;
priv->card.num_dapm_routes = ARRAY_SIZE(audio_map);
priv->card.dapm_widgets = fsl_asoc_card_dapm_widgets;

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 3/3] drm: panel-simple: implement URT UMSH-8596MD-xT panel support

2015-11-24 Thread Maciej S. Szmigiero
On 08.10.2015 10:24, Thierry Reding wrote:
> On Wed, Oct 07, 2015 at 11:02:20PM +0200, Maciej S. Szmigiero wrote:
>> This patch implements support for United Radiant Technology
>> UMSH-8596MD-xT 7.0" WVGA TFT LCD panels in DRM panel-simple
>> driver.
>>
>> Signed-off-by: Maciej Szmigiero <m...@maciej.szmigiero.name>
>> ---
>> This replaces "drm: panel-simple: add URT UMSH-8596MD-xT panel support"
>> submission.
>>
>>  drivers/gpu/drm/panel/panel-simple.c | 54 
>> 
>>  1 file changed, 54 insertions(+)
> 
> Looks good to me. I'll wait for Rob or anyone else to ack the vendor
> prefix before merging this.
> 
> Thierry

Is anybody there who can ack this prefix?

Maciej Szmigiero

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] of: Add United Radiant Technology Corporation vendor prefix

2016-02-04 Thread Maciej S. Szmigiero
Add vendor prefix for United Radiant Technology Corporation,
a provider of liquid crystal display technologies.

Signed-off-by: Maciej S. Szmigiero <m...@maciej.szmigiero.name>
---
 Documentation/devicetree/bindings/vendor-prefixes.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
b/Documentation/devicetree/bindings/vendor-prefixes.txt
index 72e2c5a2b327..1bcef7300b37 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -240,6 +240,7 @@ tplink  TP-LINK Technologies Co., Ltd.
 tronfy Tronfy
 truly  Truly Semiconductors Limited
 upisemiuPI Semiconductor Corp.
+urtUnited Radiant Technology Corporation
 usiUniversal Scientific Industrial Co., Ltd.
 v3 V3 Semiconductor
 variscite  Variscite Ltd.


Re: mfd: as3711: set regmap config reg counts properly

2016-02-13 Thread Maciej S. Szmigiero
On 11.02.2016 18:07, Lee Jones wrote:
> On Sun, 31 Jan 2016, Maciej S. Szmigiero wrote:
> 
>> Regmap config max_register field should contain number of
>> device last register, however num_reg_defaults_raw field
>> should be set to register count instead
>> (usually one register more than max_register).
>>
>> as3711 driver had both of these fields set to the same value,
>> fix this by introducing separate defines for max register
>> number and total count of registers.
>>
>> Signed-off-by: Maciej S. Szmigiero <m...@maciej.szmigiero.name>
>> ---
>>  drivers/mfd/as3711.c   | 4 ++--
>>  include/linux/mfd/as3711.h | 3 ++-
>>  2 files changed, 4 insertions(+), 3 deletions(-)
> 
> These 3 patches should really be submitted as a threaded set, so they
> stay together in one's inbox.
> 
> Also, please submit patches using the subject line format expected by
> the subsystem.
> 
> `git log --oneline -- ` helps with this.
> 
> As you're a first time offender, I'll fix this for you this time.
> 
> Applied, thanks.

Thanks,
Maciej



Re: [PATCH 3/3] drm: panel-simple: implement URT UMSH-8596MD-xT panel support

2016-02-13 Thread Maciej S. Szmigiero
Hi Thierry,

On 08.10.2015 10:24, Thierry Reding wrote:
> On Wed, Oct 07, 2015 at 11:02:20PM +0200, Maciej S. Szmigiero wrote:
>> This patch implements support for United Radiant Technology
>> UMSH-8596MD-xT 7.0" WVGA TFT LCD panels in DRM panel-simple
>> driver.
>>
>> Signed-off-by: Maciej Szmigiero <m...@maciej.szmigiero.name>
>> ---
>> This replaces "drm: panel-simple: add URT UMSH-8596MD-xT panel support"
>> submission.
>>
>>  drivers/gpu/drm/panel/panel-simple.c | 54 
>> 
>>  1 file changed, 54 insertions(+)
> 
> Looks good to me. I'll wait for Rob or anyone else to ack the vendor
> prefix before merging this.

Now the vendor prefix has been acked, but because some files have moved
since these patches were originally submitted I will update and resubmit them.

> Thierry
 
Maciej



[PATCH 1/2] dt-bindings: Add URT UMSH-8596MD-xT panel bindings

2016-02-13 Thread Maciej S. Szmigiero
Add DT bindings for United Radiant Technology
UMSH-8596MD-xT 7.0" WVGA TFT LCD panels.

Signed-off-by: Maciej S. Szmigiero <m...@maciej.szmigiero.name>
---
This replaces "of: add URT UMSH-8596MD-xT panel DT bindings"
submission.

 .../bindings/display/panel/urt,umsh-8596md.txt   | 16 
 1 file changed, 16 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/display/panel/urt,umsh-8596md.txt

diff --git 
a/Documentation/devicetree/bindings/display/panel/urt,umsh-8596md.txt 
b/Documentation/devicetree/bindings/display/panel/urt,umsh-8596md.txt
new file mode 100644
index ..088a6cea5015
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/panel/urt,umsh-8596md.txt
@@ -0,0 +1,16 @@
+United Radiant Technology UMSH-8596MD-xT 7.0" WVGA TFT LCD panel
+
+Supported are LVDS versions (-11T, -19T) and parallel ones
+(-T, -1T, -7T, -20T).
+
+Required properties:
+- compatible: should be one of:
+  "urt,umsh-8596md-t",
+  "urt,umsh-8596md-1t",
+  "urt,umsh-8596md-7t",
+  "urt,umsh-8596md-11t",
+  "urt,umsh-8596md-19t",
+  "urt,umsh-8596md-20t".
+
+This binding is compatible with the simple-panel binding, which is specified
+in simple-panel.txt in this directory.



[PATCH 2/2] drm/panel: simple: Add URT UMSH-8596MD-xT panels support

2016-02-13 Thread Maciej S. Szmigiero
Add support for United Radiant Technology UMSH-8596MD-xT
7.0" WVGA TFT LCD panels in DRM panel-simple driver.

Signed-off-by: Maciej S. Szmigiero <m...@maciej.szmigiero.name>
---
This replaces "drm: panel-simple: implement URT UMSH-8596MD-xT panel support"
submission.

 drivers/gpu/drm/panel/panel-simple.c | 54 
 1 file changed, 54 insertions(+)

diff --git a/drivers/gpu/drm/panel/panel-simple.c 
b/drivers/gpu/drm/panel/panel-simple.c
index f88a631c43ab..6530c1ffca2c 100644
--- a/drivers/gpu/drm/panel/panel-simple.c
+++ b/drivers/gpu/drm/panel/panel-simple.c
@@ -1176,6 +1176,42 @@ static const struct panel_desc shelly_sca07010_bfn_lnn = 
{
.bus_format = MEDIA_BUS_FMT_RGB666_1X18,
 };
 
+static const struct display_timing urt_umsh_8596md_timing = {
+   .pixelclock = { 3326, 3326, 3326 },
+   .hactive = { 800, 800, 800 },
+   .hfront_porch = { 41, 41, 41 },
+   .hback_porch = { 216 - 128, 216 - 128, 216 - 128 },
+   .hsync_len = { 71, 128, 128 },
+   .vactive = { 480, 480, 480 },
+   .vfront_porch = { 10, 10, 10 },
+   .vback_porch = { 35 - 2, 35 - 2, 35 - 2 },
+   .vsync_len = { 2, 2, 2 },
+   .flags = DISPLAY_FLAGS_DE_HIGH | DISPLAY_FLAGS_PIXDATA_NEGEDGE |
+   DISPLAY_FLAGS_HSYNC_LOW | DISPLAY_FLAGS_VSYNC_LOW,
+};
+
+static const struct panel_desc urt_umsh_8596md_lvds = {
+   .timings = _umsh_8596md_timing,
+   .num_timings = 1,
+   .bpc = 6,
+   .size = {
+   .width = 152,
+   .height = 91,
+   },
+   .bus_format = MEDIA_BUS_FMT_RGB666_1X7X3_SPWG,
+};
+
+static const struct panel_desc urt_umsh_8596md_parallel = {
+   .timings = _umsh_8596md_timing,
+   .num_timings = 1,
+   .bpc = 6,
+   .size = {
+   .width = 152,
+   .height = 91,
+   },
+   .bus_format = MEDIA_BUS_FMT_RGB666_1X18,
+};
+
 static const struct of_device_id platform_of_match[] = {
{
.compatible = "ampire,am800480r3tmqwa1h",
@@ -1280,6 +1316,24 @@ static const struct of_device_id platform_of_match[] = {
.compatible = "shelly,sca07010-bfn-lnn",
.data = _sca07010_bfn_lnn,
}, {
+   .compatible = "urt,umsh-8596md-t",
+   .data = _umsh_8596md_parallel,
+   }, {
+   .compatible = "urt,umsh-8596md-1t",
+   .data = _umsh_8596md_parallel,
+   }, {
+   .compatible = "urt,umsh-8596md-7t",
+   .data = _umsh_8596md_parallel,
+   }, {
+   .compatible = "urt,umsh-8596md-11t",
+   .data = _umsh_8596md_lvds,
+   }, {
+   .compatible = "urt,umsh-8596md-19t",
+   .data = _umsh_8596md_lvds,
+   }, {
+   .compatible = "urt,umsh-8596md-20t",
+   .data = _umsh_8596md_parallel,
+   }, {
/* sentinel */
}
 };



Re: [PATCH] ASoC: fsl_ssi: remove explicit register defaults

2016-02-01 Thread Maciej S. Szmigiero
On 01.02.2016 22:10, Mark Brown wrote:
> On Mon, Feb 01, 2016 at 05:58:06PM +0100, Maciej S. Szmigiero wrote:
> 
>> Looks like a possible solution would be to change
>> regmap_raw_read() to do read using _regmap_read in
>> case the cache is bypassed and there is no ->read
>> callback defined for regmap implementation.
> 
> No, that's completely broken.  We can't do a raw read from a regmap that
> doesn't offer raw access and we shouldn't pretend to do so.  If the
> caller is capable of substituting a register by register read the caller
> should take responsibility for that.

So can regcache initialization be changed to use register by register read
in case raw read fails?

Since other option for drivers like SSI which are memory mapped and
don't offer ability to reset their register values to default would be to
explicitly write driver hardcoded defaults also by doing
register by register write on probe time.

But this would force driver to keep the defaults which I think is bad
(especially for driver that supports multiple generations of hardware
like fsl_ssi which may have different default values).

Maciej



Re: [PATCH 2/2] regmap: cache: Fall back to register by register read for cache defaults

2016-02-01 Thread Maciej S. Szmigiero
On 01.02.2016 23:13, Mark Brown wrote:
> On Mon, Feb 01, 2016 at 07:58:54PM -0200, Fabio Estevam wrote:
>> On Mon, Feb 1, 2016 at 7:41 PM, Mark Brown  wrote:
>>> On Mon, Feb 01, 2016 at 09:38:15PM +, Mark Brown wrote:
 If we are unable to read the cache defaults for a regmap then fall back
 on attempting to read them word by word. This is going to be painfully
 slow for large regmaps but might be adequate for smaller ones.
> 
>>> Competely untested, hopefully it helps fix the issues with the SSI.
> 
>> After applying this series I get:
> 
> Please try to fix it yourself, probably needs setting cache_bypass
> around the manual fill.

Thanks for patches.

I was able to make SSI work again after modifying second patch
with cache_bypass around read and skipping of unreadable regs:
diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c
index 5c5090b..4170b7d 100644
--- a/drivers/base/regmap/regcache.c
+++ b/drivers/base/regmap/regcache.c
@@ -30,7 +30,7 @@ static int regcache_hw_init(struct regmap *map)
int i, j;
int ret;
int count;
-   unsigned int val;
+   unsigned int reg, val;
void *tmp_buf;
 
if (!map->num_reg_defaults_raw)
@@ -67,27 +67,46 @@ static int regcache_hw_init(struct regmap *map)
ret = regmap_raw_read(map, 0, tmp_buf,
  map->cache_size_raw);
map->cache_bypass = cache_bypass;
-   if (ret < 0)
-   goto err_cache_free;
-
-   map->reg_defaults_raw = tmp_buf;
-   map->cache_free = 1;
+   if (ret == 0) {
+   map->reg_defaults_raw = tmp_buf;
+   map->cache_free = 1;
+   } else {
+   kfree(tmp_buf);
+   }
}
 
/* fill the reg_defaults */
for (i = 0, j = 0; i < map->num_reg_defaults_raw; i++) {
-   if (regmap_volatile(map, i * map->reg_stride))
+   reg = i * map->reg_stride;
+
+   if (!regmap_readable(map, reg))
continue;
-   val = regcache_get_val(map, map->reg_defaults_raw, i);
-   map->reg_defaults[j].reg = i * map->reg_stride;
+
+   if (regmap_volatile(map, reg))
+   continue;
+
+   if (map->reg_defaults_raw) {
+   val = regcache_get_val(map, map->reg_defaults_raw, i);
+   } else {
+   bool cache_bypass = map->cache_bypass;
+
+   map->cache_bypass = true;
+   ret = regmap_read(map, reg, );
+   map->cache_bypass = cache_bypass;
+   if (ret != 0) {
+   dev_err(map->dev, "Failed to read %d: %d\n",
+   reg, ret);
+   goto err_free;
+   }
+   }
+
+   map->reg_defaults[j].reg = reg;
map->reg_defaults[j].def = val;
j++;
}
 
return 0;
 
-err_cache_free:
-   kfree(tmp_buf);
 err_free:
kfree(map->reg_defaults);
 

 


mfd: tps65090: set regmap config reg counts properly

2016-01-31 Thread Maciej S. Szmigiero
Regmap config max_register field should contain number of
device last register, however num_reg_defaults_raw field
should be set to register count instead
(usually one register more than max_register).

tps65090 driver had both of these fields set to the same value,
fix this by introducing separate defines for max register
number and total count of registers.

Signed-off-by: Maciej S. Szmigiero <m...@maciej.szmigiero.name>
---
 drivers/mfd/tps65090.c   | 5 ++---
 include/linux/mfd/tps65090.h | 5 +
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/mfd/tps65090.c b/drivers/mfd/tps65090.c
index f88085ad9772..d7ec318c40c3 100644
--- a/drivers/mfd/tps65090.c
+++ b/drivers/mfd/tps65090.c
@@ -30,7 +30,6 @@
 #include 
 
 #define NUM_INT_REG 2
-#define TOTAL_NUM_REG 0x18
 
 #define TPS65090_INT1_MASK_VAC_STATUS_CHANGE   1
 #define TPS65090_INT1_MASK_VSYS_STATUS_CHANGE  2
@@ -161,8 +160,8 @@ static bool is_volatile_reg(struct device *dev, unsigned 
int reg)
 static const struct regmap_config tps65090_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
-   .max_register = TOTAL_NUM_REG,
-   .num_reg_defaults_raw = TOTAL_NUM_REG,
+   .max_register = TPS65090_MAX_REG,
+   .num_reg_defaults_raw = TPS65090_NUM_REGS,
.cache_type = REGCACHE_RBTREE,
.volatile_reg = is_volatile_reg,
 };
diff --git a/include/linux/mfd/tps65090.h b/include/linux/mfd/tps65090.h
index 0bf2708df150..67d144b3b8f9 100644
--- a/include/linux/mfd/tps65090.h
+++ b/include/linux/mfd/tps65090.h
@@ -77,6 +77,11 @@ enum {
 #define TPS65090_REG_CG_CTRL5  0x09
 #define TPS65090_REG_CG_STATUS10x0a
 #define TPS65090_REG_CG_STATUS20x0b
+#define TPS65090_REG_AD_OUT1   0x17
+#define TPS65090_REG_AD_OUT2   0x18
+
+#define TPS65090_MAX_REG   TPS65090_REG_AD_OUT2
+#define TPS65090_NUM_REGS  (TPS65090_MAX_REG + 1)
 
 struct tps65090 {
struct device   *dev;


mfd: rc5t583: set regmap config reg counts properly

2016-01-31 Thread Maciej S. Szmigiero
Regmap config max_register field should contain number of
device last register, however num_reg_defaults_raw field
should be set to register count instead
(usually one register more than max_register).

rc5t583 driver had both of these fields set to the same value,
fix this by introducing separate defines for max register
number and total count of registers.

Signed-off-by: Maciej S. Szmigiero <m...@maciej.szmigiero.name>
---
 drivers/mfd/rc5t583.c   | 4 ++--
 include/linux/mfd/rc5t583.h | 5 +++--
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/mfd/rc5t583.c b/drivers/mfd/rc5t583.c
index e10f02f5d551..fc2b2d93f354 100644
--- a/drivers/mfd/rc5t583.c
+++ b/drivers/mfd/rc5t583.c
@@ -241,8 +241,8 @@ static const struct regmap_config rc5t583_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
.volatile_reg = volatile_reg,
-   .max_register = RC5T583_MAX_REGS,
-   .num_reg_defaults_raw = RC5T583_MAX_REGS,
+   .max_register = RC5T583_MAX_REG,
+   .num_reg_defaults_raw = RC5T583_NUM_REGS,
.cache_type = REGCACHE_RBTREE,
 };
 
diff --git a/include/linux/mfd/rc5t583.h b/include/linux/mfd/rc5t583.h
index fd413ccab915..8d0a392e0a7f 100644
--- a/include/linux/mfd/rc5t583.h
+++ b/include/linux/mfd/rc5t583.h
@@ -28,8 +28,6 @@
 #include 
 #include 
 
-#define RC5T583_MAX_REGS   0xF8
-
 /* Maximum number of main interrupts */
 #define MAX_MAIN_INTERRUPT 5
 #define RC5T583_MAX_GPEDGE_REG 2
@@ -169,6 +167,9 @@
 #define RC5T583_RTC_AY_MONTH 0xF3
 #define RC5T583_RTC_AY_YEAR0xF4
 
+#define RC5T583_MAX_REG0xF7
+#define RC5T583_NUM_REGS   (RC5T583_MAX_REG + 1)
+
 /* RICOH_RC5T583 IRQ definitions */
 enum {
RC5T583_IRQ_ONKEY,


mfd: as3711: set regmap config reg counts properly

2016-01-31 Thread Maciej S. Szmigiero
Regmap config max_register field should contain number of
device last register, however num_reg_defaults_raw field
should be set to register count instead
(usually one register more than max_register).

as3711 driver had both of these fields set to the same value,
fix this by introducing separate defines for max register
number and total count of registers.

Signed-off-by: Maciej S. Szmigiero <m...@maciej.szmigiero.name>
---
 drivers/mfd/as3711.c   | 4 ++--
 include/linux/mfd/as3711.h | 3 ++-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/mfd/as3711.c b/drivers/mfd/as3711.c
index 94d67a6e1eb7..09e1483b99bc 100644
--- a/drivers/mfd/as3711.c
+++ b/drivers/mfd/as3711.c
@@ -108,8 +108,8 @@ static const struct regmap_config as3711_regmap_config = {
.volatile_reg = as3711_volatile_reg,
.readable_reg = as3711_readable_reg,
.precious_reg = as3711_precious_reg,
-   .max_register = AS3711_MAX_REGS,
-   .num_reg_defaults_raw = AS3711_MAX_REGS,
+   .max_register = AS3711_MAX_REG,
+   .num_reg_defaults_raw = AS3711_NUM_REGS,
.cache_type = REGCACHE_RBTREE,
 };
 
diff --git a/include/linux/mfd/as3711.h b/include/linux/mfd/as3711.h
index 38452ce1e892..34cc85864be5 100644
--- a/include/linux/mfd/as3711.h
+++ b/include/linux/mfd/as3711.h
@@ -51,7 +51,8 @@
 #define AS3711_ASIC_ID_1   0x90
 #define AS3711_ASIC_ID_2   0x91
 
-#define AS3711_MAX_REGS0x92
+#define AS3711_MAX_REG AS3711_ASIC_ID_2
+#define AS3711_NUM_REGS(AS3711_MAX_REG + 1)
 
 /* Regulators */
 enum {


Re: [PATCH] ASoC: fsl_ssi: remove explicit register defaults

2016-02-01 Thread Maciej S. Szmigiero
Hi Fabio,

On 01.02.2016 13:05, Fabio Estevam wrote:
> Hi Maciej,
> 
> On Mon, Jan 18, 2016 at 5:07 PM, Maciej S. Szmigiero
> <m...@maciej.szmigiero.name> wrote:
>> There is no guarantee that on fsl_ssi module load
>> SSI registers will have their power-on-reset values.
>>
>> In fact, if the driver is reloaded the values in
>> registers will be whatever they were set to previously.
>>
>> However, the cache needs to be fully populated at probe
>> time to avoid non-atomic allocations during register
>> access.
>>
>> Special case here is imx21-class SSI, since
>> according to datasheet it don't have SACC{ST,EN,DIS}
>> regs.
>>
>> This fixes hard lockup on fsl_ssi module reload,
>> at least in AC'97 mode.
>>
>> Fixes: 05cf237972fe ("ASoC: fsl_ssi: Add driver suspend and resume to 
>> support MEGA Fast")
>>
>> Signed-off-by: Maciej S. Szmigiero <m...@maciej.szmigiero.name>
> 
> I know I have already tested this and it worked fine on a mx6sabresd,
> but running linux-next 20160201 on a mx6sl-evk the ssi driver does not
> probe anymore:
> 
> [2.216954] fsl-asoc-card sound: ASoC: CPU DAI (null) not registered
> [2.223412] fsl-asoc-card sound: snd_soc_register_card failed (-517)
> [2.230258] imx-wm8962 sound: ASoC: CPU DAI 202c000.ssi not registered
> [2.236806] imx-wm8962 sound: snd_soc_register_card failed (-517)
> [2.244782] snvs_rtc 20cc000.snvs:snvs-rtc-lp: setting system clock
> to 1970-01-01 00:01:14 UTC (74)
> [2.285864] fsl-asoc-card sound: ASoC: CPU DAI (null) not registered
> [2.292335] fsl-asoc-card sound: snd_soc_register_card failed (-517)
> [2.299572] imx-wm8962 sound: ASoC: CPU DAI 202c000.ssi not registered
> [2.306121] imx-wm8962 sound: snd_soc_register_card failed (-517)
> 
> Reverting this patch fixes the problem.
> 
> Wandboard also has the same issue:
> 
> http://arm-soc.lixom.net/bootlogs/next/next-20160201/wandboard-arm-imx_v6_v7_defconfig.html
> 
> Any suggestions?
> 
> Thanks
> 

Is regmap patch from 
http://www.spinics.net/lists/kernel/msg2161934.html
applied to the tested tree?

Best regards,
Maciej



Re: [PATCH] ASoC: fsl_ssi: remove explicit register defaults

2016-02-01 Thread Maciej S. Szmigiero
On 01.02.2016 13:13, Fabio Estevam wrote:
> Hi Maciej,
> 
> On Mon, Feb 1, 2016 at 10:07 AM, Maciej S. Szmigiero
> <m...@maciej.szmigiero.name> wrote:
>> Is regmap patch from
>> http://www.spinics.net/lists/kernel/msg2161934.html
>> applied to the tested tree?
> 
> Yes, linux-next 20160201 contains this patch.

Hmm, I will try to build this tree on UDOO board
today and see what happens.

Maciej



[PATCH] ARM: dts: imx6qdl-udoo: add sound support

2016-01-30 Thread Maciej S. Szmigiero
Add sound support in UDOO board DT file.

Signed-off-by: Maciej S. Szmigiero <m...@maciej.szmigiero.name>
---
 arch/arm/boot/dts/imx6qdl-udoo.dtsi | 57 +
 1 file changed, 57 insertions(+)

diff --git a/arch/arm/boot/dts/imx6qdl-udoo.dtsi 
b/arch/arm/boot/dts/imx6qdl-udoo.dtsi
index 1211da894ee9..d3e54e40a017 100644
--- a/arch/arm/boot/dts/imx6qdl-udoo.dtsi
+++ b/arch/arm/boot/dts/imx6qdl-udoo.dtsi
@@ -34,6 +34,18 @@
gpio = < 12 0>;
};
};
+
+   sound {
+   compatible = "fsl,imx6q-udoo-ac97",
+"fsl,imx-audio-ac97";
+   model = "fsl,imx6q-udoo-ac97";
+   audio-cpu = <>;
+   audio-routing =
+   "RX", "Mic Jack",
+   "Headphone Jack", "TX";
+   mux-int-port = <1>;
+   mux-ext-port = <6>;
+   };
 };
 
  {
@@ -109,6 +121,36 @@
MX6QDL_PAD_SD3_DAT3__SD3_DATA3  0x17059
>;
};
+
+   pinctrl_ac97_running: ac97running {
+   fsl,pins = <
+   MX6QDL_PAD_DI0_PIN2__AUD6_TXD   0x1b0b0
+   MX6QDL_PAD_DI0_PIN3__AUD6_TXFS  0x1b0b0
+   MX6QDL_PAD_DI0_PIN4__AUD6_RXD   0x1b0b0
+   MX6QDL_PAD_DI0_PIN15__AUD6_TXC  0x1b0b0
+   MX6QDL_PAD_EIM_EB2__GPIO2_IO30  0x1b0b0
+   >;
+   };
+
+   pinctrl_ac97_warm_reset: ac97warmreset {
+   fsl,pins = <
+   MX6QDL_PAD_DI0_PIN2__AUD6_TXD   0x1b0b0
+   MX6QDL_PAD_DI0_PIN3__GPIO4_IO19 0x1b0b0
+   MX6QDL_PAD_DI0_PIN4__AUD6_RXD   0x1b0b0
+   MX6QDL_PAD_DI0_PIN15__AUD6_TXC  0x1b0b0
+   MX6QDL_PAD_EIM_EB2__GPIO2_IO30  0x1b0b0
+   >;
+   };
+
+   pinctrl_ac97_reset: ac97reset {
+   fsl,pins = <
+   MX6QDL_PAD_DI0_PIN2__GPIO4_IO18 0x1b0b0
+   MX6QDL_PAD_DI0_PIN3__GPIO4_IO19 0x1b0b0
+   MX6QDL_PAD_DI0_PIN4__AUD6_RXD   0x1b0b0
+   MX6QDL_PAD_DI0_PIN15__AUD6_TXC  0x1b0b0
+   MX6QDL_PAD_EIM_EB2__GPIO2_IO30  0x1b0b0
+   >;
+   };
};
 };
 
@@ -132,3 +174,18 @@
non-removable;
status = "okay";
 };
+
+ {
+   status = "okay";
+};
+
+ {
+   cell-index = <0>;
+   fsl,mode = "ac97-slave";
+   pinctrl-names = "ac97-running", "ac97-reset", "ac97-warm-reset";
+   pinctrl-0 = <_ac97_running>;
+   pinctrl-1 = <_ac97_reset>;
+   pinctrl-2 = <_ac97_warm_reset>;
+   ac97-gpios = < 19 0  18 0  30 0>;
+   status = "okay";
+};


Re: [PATCH] ASoC: fsl_ssi: remove explicit register defaults

2016-02-01 Thread Maciej S. Szmigiero
On 01.02.2016 13:25, Maciej S. Szmigiero wrote:
> On 01.02.2016 13:13, Fabio Estevam wrote:
>> Hi Maciej,
>>
>> On Mon, Feb 1, 2016 at 10:07 AM, Maciej S. Szmigiero
>> <m...@maciej.szmigiero.name> wrote:
>>> Is regmap patch from
>>> http://www.spinics.net/lists/kernel/msg2161934.html
>>> applied to the tested tree?
>>
>> Yes, linux-next 20160201 contains this patch.
> 
> Hmm, I will try to build this tree on UDOO board
> today and see what happens.

Looks like the problem occurs because commit
922a9f936e40 ("regmap: mmio: Convert to regmap_bus and fix accessor usage")
has removed ->read callback from MMIO regmap
implementation but it is used (via regmap_raw_read()) by
regcache code to initialize cache if reg default values
weren't provided explicitly.

If I revert this commit the SSI probes successfully again.

Looks like a possible solution would be to change
regmap_raw_read() to do read using _regmap_read in
case the cache is bypassed and there is no ->read
callback defined for regmap implementation.

Maciej



  1   2   3   4   5   6   7   8   9   10   >