[linux-sunxi] Re: [PATCH 08/14] dt-bindings: sound: Add sun8i analog codec documentation

2016-10-04 Thread Chen-Yu Tsai
On Wed, Oct 5, 2016 at 12:24 AM, Maxime Ripard
 wrote:
> Hi,
>
> On Tue, Oct 04, 2016 at 11:46:21AM +0200, Mylène Josserand wrote:
>> Add the documentation for dt-binding of the analog audiocodec
>> driver for SUN8I SoC.
>>
>> Signed-off-by: Mylène Josserand 
>> ---
>>  .../devicetree/bindings/sound/sun8i-codec-analog.txt | 20 
>> 
>>  1 file changed, 20 insertions(+)
>>  create mode 100644 
>> Documentation/devicetree/bindings/sound/sun8i-codec-analog.txt
>>
>> diff --git a/Documentation/devicetree/bindings/sound/sun8i-codec-analog.txt 
>> b/Documentation/devicetree/bindings/sound/sun8i-codec-analog.txt
>> new file mode 100644
>> index 000..a03ec20
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/sound/sun8i-codec-analog.txt
>> @@ -0,0 +1,20 @@
>> +* Allwinner A23/A33 Analog Codec
>> +
>> +This codec must be handled as a PRCM subnode.
>
> Like Mark was saying, you should probably reference the sun6i-prcm.txt
> binding here
>
>> +Required properties:
>> +- compatible: must be either "allwinner,sun8i-codec-analog"
>
> Our compatible prefix is -, and using the older SoC that
> introduced that block.
>
> In this case, that would be sun6i-a31, I think?

sun6i-a31s actually, but a31s has extra line out controls,
so the right one would be sun8i-a23. Both are listed in my
original driver.

ChenYu

>
> Thanks,
> Maxime
>
> --
> Maxime Ripard, Free Electrons
> Embedded Linux and Kernel engineering
> http://free-electrons.com

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [linux-sunxi] A31s with Mainline Kernel won't boot (or not mounting the root partition)

2016-10-04 Thread Marcos Cruz
Hi,


Thank you for the reply. I'm going to apply and test your ideas as soon 
as I can.


> > Without the DT and the schematics or the FEX file, it's quite hard to 
> > tell. 
>
>  
I have attached the FEX file on this e-mail. The DT was in my first 
email, I have attached it again. It is incomplete.


Thank you,


Marcos

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


sys_config.fex
Description: Binary data


sun6i-a31s-sigmasys.dts
Description: Binary data


Re: [linux-sunxi] A31s with Mainline Kernel won't boot (or not mounting the root partition)

2016-10-04 Thread Maxime Ripard
Hi,

On Tue, Oct 04, 2016 at 07:40:05AM -0700, Marcos Cruz wrote:
> Hi all,
> 
> 
> I am trying upgrade the kernel of a board to mainline kernel (4.7.4) 
> and I'm having difficulties with the booting procedure after the upgrade. 
> This board hasn't a dts file available in the kernel, I had to write 
> one and I believe this is the likely source of the problem.
> The board actually boots but it is not mounting the root partition (it 
> is an eMMC, /dev/mmcblk0p7). After some messages sent over the serial line, 
> the kernel disables some board power sources and stops sending data. 
> Probably there are more messages to be sent.
> Anyone knows what's wrong? The board works flawlessly with an older 
> kernel (3.3.0) and the older tools provided by the people that developed 
> this board.

Without the DT and the schematics or the FEX file, it's quite hard to
tell.

> Uncompressing Linux...
>  done, booting the kernel.
> [0.00] Booting Linux on physical CPU 0x0
> [0.00] Linux version 4.7.4 (marcos@fulgore) (gcc version 4.9.1 
> (Buildroot 2014.08-8-gb374d79-dirty) ) #32 SMP Thu Sep 29 16:52:23 BRT 
> 2016
> [0.00] CPU: ARMv7 Processor [410fc073] revision 3 (ARMv7), cr=10c5387d
> [0.00] CPU: div instructions available: patching division code
> [0.00] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing 
> instruction cache
> [0.00] Machine model: Medidor Sigmasys v0
> [0.00] bootconsole [earlycon0] enabled
> [0.00] Memory policy: Data cache writealloc
> [0.00] percpu: Embedded 13 pages/cpu @ef7ad000 s22400 r8192 d22656 
> u53248
> [0.00] Built 1 zonelists in Zone order, mobility grouping on.  Total 
> pages: 260608
> [0.00] Kernel command line: console=ttyS0,115200 root=/dev/mmcblk0p7 
> init=/init loglevel=7 
> partitions=bootloader@mmcblk0p2:env@mmcblk0p5:boot@mmcblk0p6:rootfs@mmcblk0p7:UDISK@mmcblk0p1
>  earlyprintk
> [0.00] PID hash table entries: 4096 (order: 2, 16384 bytes)
> [0.00] Dentry cache hash table entries: 131072 (order: 7, 524288 
> bytes)
> [0.00] Inode-cache hash table entries: 65536 (order: 6, 262144 bytes)
> [0.00] Memory: 1030528K/1048576K available (5273K kernel code, 249K 
> rwdata, 1412K rodata, 1024K init, 249K bss, 18048K reserved, 0K cma-reserved, 
> 262144K highmem)
> [0.00] Virtual kernel memory layout:
> [0.00] vector  : 0x - 0x1000   (   4 kB)
> [0.00] fixmap  : 0xffc0 - 0xfff0   (3072 kB)
> [0.00] vmalloc : 0xf080 - 0xff80   ( 240 MB)
> [0.00] lowmem  : 0xc000 - 0xf000   ( 768 MB)
> [0.00] pkmap   : 0xbfe0 - 0xc000   (   2 MB)
> [0.00] modules : 0xbf00 - 0xbfe0   (  14 MB)
> [0.00]   .text : 0xc0008000 - 0xc07877d8   (7678 kB)
> [0.00]   .init : 0xc080 - 0xc090   (1024 kB)
> [0.00]   .data : 0xc090 - 0xc093e6e0   ( 250 kB)
> [0.00].bss : 0xc094 - 0xc097e44c   ( 250 kB)
> [0.00] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1
> [0.00] Hierarchical RCU implementation.
> [0.00] \0x09Build-time adjustment of leaf fanout to 32.
> [0.00] \0x09RCU restricting CPUs from NR_CPUS=8 to nr_cpu_ids=4.
> [0.00] RCU: Adjusting geometry for rcu_fanout_leaf=32, nr_cpu_ids=4
> [0.00] NR_IRQS:16 nr_irqs:16 16
> [0.00] Architected cp15 timer(s) running at 24.00MHz (phys).
> [0.00] clocksource: arch_sys_counter: mask: 0xff 
> max_cycles: 0x588fe9dc0, max_idle_ns: 440795202592 ns
> [0.06] sched_clock: 56 bits at 24MHz, resolution 41ns, wraps every 
> 4398046511097ns
> [0.008086] Switching to timer-based delay loop, resolution 41ns
> [0.014374] clocksource: timer: mask: 0x max_cycles: 0x, 
> max_idle_ns: 79635851949 ns
> [0.023681] clocksource: timer: mask: 0x max_cycles: 0x, 
> max_idle_ns: 12741736309 ns
> [0.033158] Console: colour dummy device 80x30
> [0.037694] Calibrating delay loop (skipped), value calculated using timer 
> frequency.. 48.00 BogoMIPS (lpj=24)
> [0.048136] pid_max: default: 32768 minimum: 301
> [0.052914] Mount-cache hash table entries: 2048 (order: 1, 8192 bytes)
> [0.059615] Mountpoint-cache hash table entries: 2048 (order: 1, 8192 
> bytes)
> [0.067310] CPU: Testing write buffer coherency: ok
> [0.072559] /cpus/cpu@0 missing clock-frequency property
> [0.077954] /cpus/cpu@1 missing clock-frequency property
> [0.083371] /cpus/cpu@2 missing clock-frequency property
> [0.088765] /cpus/cpu@3 missing clock-frequency property
> [0.094168] CPU0: thread -1, cpu 0, socket 0, mpidr 8000
> [0.100072] Setting up static identity map for 0x4010 - 0x40100058
> [0.119023] CPU1: thread -1, cpu 1, socket 0, mpidr 8001
> [0.130609] CPU2: thread -1, 

[linux-sunxi] Re: [PATCH 01/14] dma: sun6i-dma: Add burst case of 4

2016-10-04 Thread Maxime Ripard
On Tue, Oct 04, 2016 at 12:40:11PM +0200, Jean-Francois Moine wrote:
> On Tue,  4 Oct 2016 11:46:14 +0200
> Mylène Josserand  wrote:
> 
> > Add the case of a burst of 4 which is handled by the SoC.
> > 
> > Signed-off-by: Mylène Josserand 
> > ---
> >  drivers/dma/sun6i-dma.c | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/drivers/dma/sun6i-dma.c b/drivers/dma/sun6i-dma.c
> > index 8346199..0485204 100644
> > --- a/drivers/dma/sun6i-dma.c
> > +++ b/drivers/dma/sun6i-dma.c
> > @@ -240,6 +240,8 @@ static inline s8 convert_burst(u32 maxburst)
> > switch (maxburst) {
> > case 1:
> > return 0;
> > +   case 4:
> > +   return 1;
> > case 8:
> > return 2;
> > default:
> > -- 
> > 2.9.3
> 
> This patch has already been rejected by Maxime in the threads
>   http://www.spinics.net/lists/dmaengine/msg08610.html
> and
>   http://www.spinics.net/lists/dmaengine/msg08719.html
> 
> I hope you will find the way he wants for this maxburst to be added.

I was talking about something along these lines (not tested):

---8<-
diff --git a/drivers/dma/sun6i-dma.c b/drivers/dma/sun6i-dma.c
index 83461994e418..573ac4608293 100644
--- a/drivers/dma/sun6i-dma.c
+++ b/drivers/dma/sun6i-dma.c
@@ -240,6 +240,8 @@ static inline s8 convert_burst(u32 maxburst)
switch (maxburst) {
case 1:
return 0;
+   case 4:
+   return 1;
case 8:
return 2;
default:
@@ -1110,11 +1112,19 @@ static int sun6i_dma_probe(struct platform_device *pdev)
sdc->slave.dst_addr_widths  = 
BIT(DMA_SLAVE_BUSWIDTH_1_BYTE) |
  
BIT(DMA_SLAVE_BUSWIDTH_2_BYTES) |
  
BIT(DMA_SLAVE_BUSWIDTH_4_BYTES);
+   sdc->slave.dst_bursts   = BIT(1) | BIT(8);
+   sdc->slave.src_bursts   = BIT(1) | BIT(8);
sdc->slave.directions   = BIT(DMA_DEV_TO_MEM) |
  BIT(DMA_MEM_TO_DEV);
sdc->slave.residue_granularity  = DMA_RESIDUE_GRANULARITY_BURST;
sdc->slave.dev = >dev;
 
+   if (of_device_is_compatible(pdev->dev.of_node,
+   "allwinner,sun8i-h3-dma")) {
+   sdc->slave.dst_bursts |= BIT(4);
+   sdc->slave.src_bursts |= BIT(4);
+   }
+
sdc->pchans = devm_kcalloc(>dev, sdc->cfg->nr_max_channels,
   sizeof(struct sun6i_pchan), GFP_KERNEL);
if (!sdc->pchans)
diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
index cc535a478bae..f7bbec24bb58 100644
--- a/include/linux/dmaengine.h
+++ b/include/linux/dmaengine.h
@@ -673,6 +673,8 @@ struct dma_filter {
  * each type of direction, the dma controller should fill (1 <<
  * ) and same should be checked by controller as well
  * @max_burst: max burst capability per-transfer
+ * @dst_bursts: bitfield of the available burst sizes for the destination
+ * @src_bursts: bitfield of the available burst sizes for the source
  * @residue_granularity: granularity of the transfer residue reported
  * by tx_status
  * @device_alloc_chan_resources: allocate resources and return the
@@ -800,6 +802,14 @@ struct dma_device {
 static inline int dmaengine_slave_config(struct dma_chan *chan,
  struct dma_slave_config *config)
 {
+   if (config->src_maxburst && config->device->src_bursts &&
+   !(BIT(config->src_maxburst) & config->device->src_bursts))
+   return -EINVAL;
+
+   if (config->dst_maxburst && config->device->dst_bursts &&
+   !(BIT(config->dst_maxburst) & config->device->dst_bursts))
+   return -EINVAL;
+
if (chan->device->device_config)
return chan->device->device_config(chan, config);
---8< 

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: PGP signature


[linux-sunxi] Re: [PATCH 10/14] dt-bindings: sound: Add sun8i audio card documentation

2016-10-04 Thread Maxime Ripard
On Tue, Oct 04, 2016 at 11:46:23AM +0200, Mylène Josserand wrote:
> Add the documentation for dt-binding of the audio card driver
> for sun8i SoC.
> 
> Signed-off-by: Mylène Josserand 
> ---
>  Documentation/devicetree/bindings/sound/sun8i-audio.txt | 17 
> +
>  1 file changed, 17 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/sound/sun8i-audio.txt
> 
> diff --git a/Documentation/devicetree/bindings/sound/sun8i-audio.txt 
> b/Documentation/devicetree/bindings/sound/sun8i-audio.txt
> new file mode 100644
> index 000..2403983
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/sound/sun8i-audio.txt
> @@ -0,0 +1,17 @@
> +* Allwinner A23/A33 audio card
> +
> +This binding implements the A33 audio card.
> +
> +Required properties:
> +- compatible: must be "allwinner,sun8i-audio"
> +- allwinner,audio-codec: must have the phandle of the audio codec
> +  ("sun8i-a33-codec", for example).
> +- allwinner,i2s-controller: must have the phandle of the DAI
> +  ("allwinner,sun4i-a10-i2s", for example)

You should probably have a link to the PRCM too, instead of relying on
the name of the device in your card, which is quite fragile.

Also, I'm wondering, shouldn't all these nodes be part of a single
MFD? They share the same address space (even though it's split
nicely), the same clocks, and really are just one big device. Chen-Yu,
Mark, any opinion?

Thanks,
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: PGP signature


[linux-sunxi] Re: [PATCH 08/14] dt-bindings: sound: Add sun8i analog codec documentation

2016-10-04 Thread Maxime Ripard
Hi,

On Tue, Oct 04, 2016 at 11:46:21AM +0200, Mylène Josserand wrote:
> Add the documentation for dt-binding of the analog audiocodec
> driver for SUN8I SoC.
> 
> Signed-off-by: Mylène Josserand 
> ---
>  .../devicetree/bindings/sound/sun8i-codec-analog.txt | 20 
> 
>  1 file changed, 20 insertions(+)
>  create mode 100644 
> Documentation/devicetree/bindings/sound/sun8i-codec-analog.txt
> 
> diff --git a/Documentation/devicetree/bindings/sound/sun8i-codec-analog.txt 
> b/Documentation/devicetree/bindings/sound/sun8i-codec-analog.txt
> new file mode 100644
> index 000..a03ec20
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/sound/sun8i-codec-analog.txt
> @@ -0,0 +1,20 @@
> +* Allwinner A23/A33 Analog Codec
> +
> +This codec must be handled as a PRCM subnode.

Like Mark was saying, you should probably reference the sun6i-prcm.txt
binding here

> +Required properties:
> +- compatible: must be either "allwinner,sun8i-codec-analog"

Our compatible prefix is -, and using the older SoC that
introduced that block.

In this case, that would be sun6i-a31, I think?

Thanks,
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: PGP signature


[linux-sunxi] Re: [PATCH 09/14] dt-bindings: sound: Add sun8i codec documentation

2016-10-04 Thread Maxime Ripard
On Tue, Oct 04, 2016 at 11:46:22AM +0200, Mylène Josserand wrote:
> Add the documentation for dt-binding of the digital audio codec driver
> for sun8i SoC.
> 
> Signed-off-by: Mylène Josserand 
> ---
>  .../devicetree/bindings/sound/sun8i-codec.txt  | 24 
> ++
>  1 file changed, 24 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/sound/sun8i-codec.txt
> 
> diff --git a/Documentation/devicetree/bindings/sound/sun8i-codec.txt 
> b/Documentation/devicetree/bindings/sound/sun8i-codec.txt
> new file mode 100644
> index 000..1808869
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/sound/sun8i-codec.txt
> @@ -0,0 +1,24 @@
> +* Allwinner A23/A33 Codec
> +
> +Required properties:
> +- compatible: must be either "allwinner,sun4i-a23-codec" or
> +  "allwinner,sun7i-a33-codec"

Copy and paste issue ? :)

One compatible by line is usually favored, since when you'll add new
compatibles, you don't have to modify the context.xs

> +- reg: must contain the registers location and length
> +- interrupts: must contain the codec interrupt
> +- clocks: a list of phandle + clock-specifer pairs, one for each entry
> +  in clock-names.
> +- clock-names: should contain followings:
> +   - "apb": the parent APB clock for this controller
> +   - "codec": the parent module clock

We're usually calling them "bus" and "mod".

> +
> +Example:
> +codec: codec@01c22e00 {
> + #sound-dai-cells = <0>;
> + compatible = "allwinner,sun8i-a33-codec";
> + reg = <0x01c22e00 0x400>; /* SUNXI_AUDIO_PBASE + 0x200 */
> + reg-names = "audio";

You don't define reg-names in your bindings, while your code relies on
it. It isn't really needed, since you have only one couple of base +
size, so it should just go away.

Thanks!
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: PGP signature


[linux-sunxi] Re: [PATCH 06/14] ASoC: Add sun8i digital audio codec

2016-10-04 Thread Maxime Ripard
Hi,

> +static const struct of_device_id sun8i_codec_of_match[] = {
> + { .compatible = "allwinner,sun8i-a33-codec" },
> + { .compatible = "allwinner,sun8i-a23-codec" },

I thought that the A23 and A33 had different codecs? In that case, it
wouldn't be a good assumption to make


> + {}
> +};
> +MODULE_DEVICE_TABLE(of, sun8i_codec_of_match);
> +
> +static struct platform_driver sun8i_codec_driver = {
> + .driver = {
> + .name = "sun8i-codec",
> + .owner = THIS_MODULE,
> + .of_match_table = sun8i_codec_of_match,
> + },
> + .probe = sun8i_codec_probe,
> + .remove = sun8i_codec_remove,
> +};
> +module_platform_driver(sun8i_codec_driver);
> +
> +MODULE_DESCRIPTION("Allwinner A33 (sun8i) codec driver");
> +MODULE_AUTHOR("huanxin");

Those obfuscated email adresses are not really helpful :)

Thanks,
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: PGP signature


[linux-sunxi] Re: [PATCH 06/14] ASoC: Add sun8i digital audio codec

2016-10-04 Thread Maxime Ripard
Hi,

On Tue, Oct 04, 2016 at 02:40:08PM +0200, Thomas Petazzoni wrote:
> > +   scodec->clk_apb = devm_clk_get(>dev, "apb");
> > +   if (IS_ERR(scodec->clk_apb)) {
> > +   dev_err(>dev, "Failed to get the apb clock\n");
> > +   return PTR_ERR(scodec->clk_apb);
> > +   }
> > +   if (clk_prepare_enable(scodec->clk_apb))
> > +   pr_err("err:open failed;\n");
> 
> Ditto. + unprepare/disable the previous clock.

Ideally, that would be even not be part of the runtime_pm
hooks. Ideally, that would be great if that driver supports it.

We'll have to go through all the drivers to support it, that would be
one less to do (and ASoC makes it very easy, you can have a look at
the sun4i-i2s driver).

Thanks!
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: PGP signature


Re: [linux-sunxi] Re: [RFC 6/6] drm/sun4i: Add various bits and pieces to enable LVDS support on sun4i

2016-10-04 Thread Priit Laes
On Mon, 2016-10-03 at 14:04 +0200, Maxime Ripard wrote:
> On Sun, Oct 02, 2016 at 12:22:27PM +0300, Priit Laes wrote:
> > 
> > TODO: We still rely on u-boot for clock setup.
> > Signed-off-by: Priit Laes 
> 
> All of that should be in the LVDS file you added in the previous
> patch.

Can I also rip out the bridge stuff as this seems to be only RGB-
specific (DAC stuff?)?

Päikest,
Priit Laes ;)

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] Re: [PATCH 1/3] pinctrl: sunxi: Add support for fetching pinconf settings from hardware

2016-10-04 Thread Chen-Yu Tsai
On Tue, Oct 4, 2016 at 4:02 PM, Maxime Ripard
 wrote:
> On Tue, Oct 04, 2016 at 09:51:10AM +0800, Chen-Yu Tsai wrote:
>> The sunxi pinctrl driver only caches whatever pinconf setting was last
>> set on a given pingroup. This is not particularly helpful, nor is it
>> correct.
>>
>> Fix this by actually reading the hardware registers and returning
>> the correct results or error codes. Also filter out unsupported
>> pinconf settings. Since this driver has a peculiar setup of 1 pin
>> per group, we can support both pin and pingroup pinconf setting
>> read back with the same code. The sunxi_pconf_reg helper and code
>> structure is inspired by pinctrl-msm.
>>
>> With this done we can also claim to support generic pinconf, by
>> setting .is_generic = true in pinconf_ops.
>>
>> Signed-off-by: Chen-Yu Tsai 
>> ---
>>  drivers/pinctrl/sunxi/pinctrl-sunxi.c | 85 
>> +--
>>  1 file changed, 82 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c 
>> b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
>> index 54455af566ec..609843c9a65c 100644
>> --- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c
>> +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
>> @@ -10,6 +10,7 @@
>>   * warranty of any kind, whether express or implied.
>>   */
>>
>> +#include 
>>  #include 
>>  #include 
>>  #include 
>> @@ -269,15 +270,91 @@ static const struct pinctrl_ops sunxi_pctrl_ops = {
>>   .get_group_pins = sunxi_pctrl_get_group_pins,
>>  };
>>
>> +static int sunxi_pconf_reg(unsigned pin, enum pin_config_param param,
>> +u32 *offset, u32 *shift, u32 *mask)
>> +{
>> + switch (param) {
>> + case PIN_CONFIG_DRIVE_STRENGTH:
>> + *offset = sunxi_dlevel_reg(pin);
>> + *shift = sunxi_dlevel_offset(pin);
>> + *mask = DLEVEL_PINS_MASK;
>> + break;
>> +
>> + case PIN_CONFIG_BIAS_PULL_UP:
>> + case PIN_CONFIG_BIAS_PULL_DOWN:
>> + case PIN_CONFIG_BIAS_DISABLE:
>> + *offset = sunxi_pull_reg(pin);
>> + *shift = sunxi_pull_offset(pin);
>> + *mask = PULL_PINS_MASK;
>> + break;
>> +
>> + default:
>> + return -ENOTSUPP;
>> + }
>> +
>> + return 0;
>> +}
>> +
>> +static int sunxi_pconf_get(struct pinctrl_dev *pctldev, unsigned pin,
>> +unsigned long *config)
>> +{
>> + struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
>> + enum pin_config_param param = pinconf_to_config_param(*config);
>> + u32 offset, shift, mask, val;
>> + u16 arg;
>> + int ret;
>> +
>> + pin -= pctl->desc->pin_base;
>> +
>> + ret = sunxi_pconf_reg(pin, param, , , );
>> + if (ret < 0)
>> + return ret;
>> +
>> + val = (readl(pctl->membase + offset) >> shift) & mask;
>> +
>> + switch (pinconf_to_config_param(*config)) {
>> + case PIN_CONFIG_DRIVE_STRENGTH:
>> + arg = (val + 1) * 10;
>> + break;
>> +
>> + case PIN_CONFIG_BIAS_PULL_UP:
>> + if (val != SUN4I_PINCTRL_PULL_UP)
>> + return -EINVAL;
>> + arg = 1; /* hardware is weak pull-up */
>> + break;
>> +
>> + case PIN_CONFIG_BIAS_PULL_DOWN:
>> + if (val != SUN4I_PINCTRL_PULL_DOWN)
>> + return -EINVAL;
>> + arg = 1; /* hardware is weak pull-down */
>> + break;
>> +
>> + case PIN_CONFIG_BIAS_DISABLE:
>> + if (val != SUN4I_PINCTRL_NO_PULL)
>> + return -EINVAL;
>> + arg = 0;
>> + break;
>> +
>> + default:
>> + /* sunxi_pconf_reg should catch anything unsupported */
>> + WARN_ON(1);
>> + return -ENOTSUPP;
>
> This should be EINVAL. The operation is supported, but one of the
> argument is not valid.

According to include/linux/pinctrl/pinconf.h

 * @pin_config_get: get the config of a certain pin, if the requested config
 *  is not available on this controller this should return -ENOTSUPP
 *  and if it is available but disabled it should return -EINVAL

So I think it is correct to return -ENOTSUPP here.

ChenYu

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] Re: [PATCH 03/14] ASoC: sun4i-i2s: Add apb reset

2016-10-04 Thread Maxime Ripard
Hi,

On Tue, Oct 04, 2016 at 02:15:16PM +0200, Thomas Petazzoni wrote:
> Hello,
> 
> On Tue,  4 Oct 2016 11:46:16 +0200, Mylène Josserand wrote:
> 
> >  #include 
> >  #include 
> > @@ -589,6 +590,7 @@ static int sun4i_i2s_probe(struct platform_device *pdev)
> >  {
> > struct sun4i_i2s *i2s;
> > struct resource *res;
> > +   struct reset_control *reset_apb;
> > void __iomem *regs;
> > int irq, ret;
> >  
> > @@ -626,7 +628,19 @@ static int sun4i_i2s_probe(struct platform_device 
> > *pdev)
> > dev_err(>dev, "Can't get our mod clock\n");
> > return PTR_ERR(i2s->mod_clk);
> > }
> > -   
> > +
> > +   reset_apb = devm_reset_control_get(>dev, "apb_reset");
> 
> I believe this is a change in the Device Tree binding, since you're
> adding support for a new resource. Perhaps the Device Tree binding
> documentation should be updated accordingly?

Indeed.

You have two solutions to do that:
  - Either mark it as optional and use reset_control_get_optional
(because here, you broke the other SoCs that have that controller
but no reset line)
  - Or introduce a new compatible, and make the reset property
mandatory for that new compatible.

I prefer the latter, since you get a stricter error check, and you
cannot end up in a situation where your driver probes but is
useless. But you'll find both in our drivers.

> > +   }
> > +
> > +   ret = reset_control_deassert(reset_apb);
> > +   if (ret < 0) {
> > +   dev_err(>dev, "Can't deassert apb reset (%d)\n", ret);
> > +   return ret;
> > +   }
> 
> Do you need to re-assert the reset line in the ->remove() hook?

Even better, you can add it to the runtime_pm hooks! :)

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: PGP signature


[linux-sunxi] Re: [PATCH 01/14] dma: sun6i-dma: Add burst case of 4

2016-10-04 Thread Vinod Koul
On Tue, Oct 04, 2016 at 03:46:51PM +0200, Jean-Francois Moine wrote:
> On Tue, 4 Oct 2016 14:12:21 +0200
> Thomas Petazzoni  wrote:
> 
> > > > Add the case of a burst of 4 which is handled by the SoC.
> > > > 
> > > > Signed-off-by: Mylčne Josserand 
> > > > ---
> > > >  drivers/dma/sun6i-dma.c | 2 ++
> > > >  1 file changed, 2 insertions(+)
> > > > 
> > > > diff --git a/drivers/dma/sun6i-dma.c b/drivers/dma/sun6i-dma.c
> > > > index 8346199..0485204 100644
> > > > --- a/drivers/dma/sun6i-dma.c
> > > > +++ b/drivers/dma/sun6i-dma.c
> > > > @@ -240,6 +240,8 @@ static inline s8 convert_burst(u32 maxburst)
> > > > switch (maxburst) {
> > > > case 1:
> > > > return 0;
> > > > +   case 4:
> > > > +   return 1;
> > > > case 8:
> > > > return 2;
> > > > default:
> > > > -- 
> > > > 2.9.3  
> > > 
> > > This patch has already been rejected by Maxime in the threads
> > >   http://www.spinics.net/lists/dmaengine/msg08610.html
> > > and
> > >   http://www.spinics.net/lists/dmaengine/msg08719.html
> > > 
> > > I hope you will find the way he wants for this maxburst to be added.
> > 
> > I was about to reply to Mylene's e-mail, suggesting that she should add
> > a comment in the code (and maybe in the commit log) to explain why this
> > addition is needed, and also that even though the schematics say that
> > value "1" (max burst size of 4 bytes) is reserved, it is in fact
> > incorrect. The Allwinner BSP code is really using this value, and it's
> > the value that makes audio work, so we believe the datasheet is simply
> > incorrect.
> > 
> > We already discussed it with Maxime, so I believe he should agree this
> > time. But I would suggest to have such details explained in the commit
> > log and in a comment in the code.
> 
> Strange. Looking at the datasheets of the A23, A31, A33, A83T and H3
> (these are the SoCs using the DMA sun6i), only the H3 can have 4 as the
> burst size (the doc is unclear for the A31).
> 
> Well, I was submitting for the H3, Mylčne is submitting for the A33.
> So, what about the A23, A31 and A83T?

Since these are device properties, I feel we should move this to DT. That
way any new controller can have any variation based on the mood of hw
designer that day and we can hopefully cope with it :-)

But yes we would need to set the bursts supported in driver and allow above
for supported bursts only.

-- 
~Vinod

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] Re: [PATCH 1/3] pinctrl: sunxi: Add support for fetching pinconf settings from hardware

2016-10-04 Thread Maxime Ripard
On Tue, Oct 04, 2016 at 09:51:10AM +0800, Chen-Yu Tsai wrote:
> The sunxi pinctrl driver only caches whatever pinconf setting was last
> set on a given pingroup. This is not particularly helpful, nor is it
> correct.
> 
> Fix this by actually reading the hardware registers and returning
> the correct results or error codes. Also filter out unsupported
> pinconf settings. Since this driver has a peculiar setup of 1 pin
> per group, we can support both pin and pingroup pinconf setting
> read back with the same code. The sunxi_pconf_reg helper and code
> structure is inspired by pinctrl-msm.
> 
> With this done we can also claim to support generic pinconf, by
> setting .is_generic = true in pinconf_ops.
> 
> Signed-off-by: Chen-Yu Tsai 
> ---
>  drivers/pinctrl/sunxi/pinctrl-sunxi.c | 85 
> +--
>  1 file changed, 82 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c 
> b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
> index 54455af566ec..609843c9a65c 100644
> --- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c
> +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
> @@ -10,6 +10,7 @@
>   * warranty of any kind, whether express or implied.
>   */
>  
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -269,15 +270,91 @@ static const struct pinctrl_ops sunxi_pctrl_ops = {
>   .get_group_pins = sunxi_pctrl_get_group_pins,
>  };
>  
> +static int sunxi_pconf_reg(unsigned pin, enum pin_config_param param,
> +u32 *offset, u32 *shift, u32 *mask)
> +{
> + switch (param) {
> + case PIN_CONFIG_DRIVE_STRENGTH:
> + *offset = sunxi_dlevel_reg(pin);
> + *shift = sunxi_dlevel_offset(pin);
> + *mask = DLEVEL_PINS_MASK;
> + break;
> +
> + case PIN_CONFIG_BIAS_PULL_UP:
> + case PIN_CONFIG_BIAS_PULL_DOWN:
> + case PIN_CONFIG_BIAS_DISABLE:
> + *offset = sunxi_pull_reg(pin);
> + *shift = sunxi_pull_offset(pin);
> + *mask = PULL_PINS_MASK;
> + break;
> +
> + default:
> + return -ENOTSUPP;
> + }
> +
> + return 0;
> +}
> +
> +static int sunxi_pconf_get(struct pinctrl_dev *pctldev, unsigned pin,
> +unsigned long *config)
> +{
> + struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
> + enum pin_config_param param = pinconf_to_config_param(*config);
> + u32 offset, shift, mask, val;
> + u16 arg;
> + int ret;
> +
> + pin -= pctl->desc->pin_base;
> +
> + ret = sunxi_pconf_reg(pin, param, , , );
> + if (ret < 0)
> + return ret;
> +
> + val = (readl(pctl->membase + offset) >> shift) & mask;
> +
> + switch (pinconf_to_config_param(*config)) {
> + case PIN_CONFIG_DRIVE_STRENGTH:
> + arg = (val + 1) * 10;
> + break;
> +
> + case PIN_CONFIG_BIAS_PULL_UP:
> + if (val != SUN4I_PINCTRL_PULL_UP)
> + return -EINVAL;
> + arg = 1; /* hardware is weak pull-up */
> + break;
> +
> + case PIN_CONFIG_BIAS_PULL_DOWN:
> + if (val != SUN4I_PINCTRL_PULL_DOWN)
> + return -EINVAL;
> + arg = 1; /* hardware is weak pull-down */
> + break;
> +
> + case PIN_CONFIG_BIAS_DISABLE:
> + if (val != SUN4I_PINCTRL_NO_PULL)
> + return -EINVAL;
> + arg = 0;
> + break;
> +
> + default:
> + /* sunxi_pconf_reg should catch anything unsupported */
> + WARN_ON(1);
> + return -ENOTSUPP;

This should be EINVAL. The operation is supported, but one of the
argument is not valid.

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: PGP signature


[linux-sunxi] Re: [PATCH 3/3] pinctrl: sunxi: Make sunxi_pconf_group_set use sunxi_pconf_reg helper

2016-10-04 Thread Maxime Ripard
On Tue, Oct 04, 2016 at 09:51:12AM +0800, Chen-Yu Tsai wrote:
> The sunxi_pconf_reg helper introduced in the last patch gives us the
> chance to rework sunxi_pconf_group_set to have it match the structure
> of sunxi_pconf_(group_)get and make it easier to understand.
> 
> For each config to set, it:
> 
> 1. checks if the parameter is supported.
> 2. checks if the argument is within limits.
> 3. converts argument to the register value.
> 4. writes to the register with spinlock held.
> 
> As a result the function now blocks unsupported config parameters,
> instead of silently ignoring them.
> 
> Signed-off-by: Chen-Yu Tsai 
> ---
>  drivers/pinctrl/sunxi/pinctrl-sunxi.c | 65 
> +++
>  drivers/pinctrl/sunxi/pinctrl-sunxi.h |  1 -
>  2 files changed, 35 insertions(+), 31 deletions(-)
> 
> diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c 
> b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
> index 236272a2339d..1f02c4cd55c7 100644
> --- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c
> +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
> @@ -364,23 +364,27 @@ static int sunxi_pconf_group_set(struct pinctrl_dev 
> *pctldev,
>  {
>   struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
>   struct sunxi_pinctrl_group *g = >groups[group];
> - unsigned long flags;
>   unsigned pin = g->pin - pctl->desc->pin_base;
> - u32 val, mask;
> - u16 strength;
> - u8 dlevel;
>   int i;
>  
> - spin_lock_irqsave(>lock, flags);
> -
>   for (i = 0; i < num_configs; i++) {
> - switch (pinconf_to_config_param(configs[i])) {
> + enum pin_config_param param;
> + unsigned long flags;
> + u32 offset, shift, mask, val;
> + u16 arg;
> + int ret;
> +
> + param = pinconf_to_config_param(configs[i]);
> + arg = pinconf_to_config_argument(configs[i]);
> +
> + ret = sunxi_pconf_reg(pin, param, , , );
> + if (ret < 0)
> + return ret;
> +
> + switch (param) {
>   case PIN_CONFIG_DRIVE_STRENGTH:
> - strength = pinconf_to_config_argument(configs[i]);
> - if (strength > 40) {
> - spin_unlock_irqrestore(>lock, flags);
> + if (arg < 10 || arg > 40)

This is a nitpick, but I'd really like to store the value in a
separate variable, to have a distinction between the value that was
given us as an argument, and what we're going to write.

Thanks!
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: PGP signature


[linux-sunxi] A31s with Mainline Kernel won't boot (or not mounting the root partition)

2016-10-04 Thread Marcos Cruz
Hi all,


I am trying upgrade the kernel of a board to mainline kernel (4.7.4) 
and I'm having difficulties with the booting procedure after the upgrade. 
This board hasn't a dts file available in the kernel, I had to write 
one and I believe this is the likely source of the problem.
The board actually boots but it is not mounting the root partition (it 
is an eMMC, /dev/mmcblk0p7). After some messages sent over the serial line, 
the kernel disables some board power sources and stops sending data. 
Probably there are more messages to be sent.
Anyone knows what's wrong? The board works flawlessly with an older 
kernel (3.3.0) and the older tools provided by the people that developed 
this board.


Thank you in advance,


Marcos

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Uncompressing Linux...
 done, booting the kernel.
[0.00] Booting Linux on physical CPU 0x0
[0.00] Linux version 4.7.4 (marcos@fulgore) (gcc version 4.9.1 
(Buildroot 2014.08-8-gb374d79-dirty) ) #32 SMP Thu Sep 29 16:52:23 BRT 2016
[0.00] CPU: ARMv7 Processor [410fc073] revision 3 (ARMv7), cr=10c5387d
[0.00] CPU: div instructions available: patching division code
[0.00] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing 
instruction cache
[0.00] Machine model: Medidor Sigmasys v0
[0.00] bootconsole [earlycon0] enabled
[0.00] Memory policy: Data cache writealloc
[0.00] percpu: Embedded 13 pages/cpu @ef7ad000 s22400 r8192 d22656 
u53248
[0.00] Built 1 zonelists in Zone order, mobility grouping on.  Total 
pages: 260608
[0.00] Kernel command line: console=ttyS0,115200 root=/dev/mmcblk0p7 
init=/init loglevel=7 
partitions=bootloader@mmcblk0p2:env@mmcblk0p5:boot@mmcblk0p6:rootfs@mmcblk0p7:UDISK@mmcblk0p1
 earlyprintk
[0.00] PID hash table entries: 4096 (order: 2, 16384 bytes)
[0.00] Dentry cache hash table entries: 131072 (order: 7, 524288 bytes)
[0.00] Inode-cache hash table entries: 65536 (order: 6, 262144 bytes)
[0.00] Memory: 1030528K/1048576K available (5273K kernel code, 249K 
rwdata, 1412K rodata, 1024K init, 249K bss, 18048K reserved, 0K cma-reserved, 
262144K highmem)
[0.00] Virtual kernel memory layout:
[0.00] vector  : 0x - 0x1000   (   4 kB)
[0.00] fixmap  : 0xffc0 - 0xfff0   (3072 kB)
[0.00] vmalloc : 0xf080 - 0xff80   ( 240 MB)
[0.00] lowmem  : 0xc000 - 0xf000   ( 768 MB)
[0.00] pkmap   : 0xbfe0 - 0xc000   (   2 MB)
[0.00] modules : 0xbf00 - 0xbfe0   (  14 MB)
[0.00]   .text : 0xc0008000 - 0xc07877d8   (7678 kB)
[0.00]   .init : 0xc080 - 0xc090   (1024 kB)
[0.00]   .data : 0xc090 - 0xc093e6e0   ( 250 kB)
[0.00].bss : 0xc094 - 0xc097e44c   ( 250 kB)
[0.00] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1
[0.00] Hierarchical RCU implementation.
[0.00] \0x09Build-time adjustment of leaf fanout to 32.
[0.00] \0x09RCU restricting CPUs from NR_CPUS=8 to nr_cpu_ids=4.
[0.00] RCU: Adjusting geometry for rcu_fanout_leaf=32, nr_cpu_ids=4
[0.00] NR_IRQS:16 nr_irqs:16 16
[0.00] Architected cp15 timer(s) running at 24.00MHz (phys).
[0.00] clocksource: arch_sys_counter: mask: 0xff 
max_cycles: 0x588fe9dc0, max_idle_ns: 440795202592 ns
[0.06] sched_clock: 56 bits at 24MHz, resolution 41ns, wraps every 
4398046511097ns
[0.008086] Switching to timer-based delay loop, resolution 41ns
[0.014374] clocksource: timer: mask: 0x max_cycles: 0x, 
max_idle_ns: 79635851949 ns
[0.023681] clocksource: timer: mask: 0x max_cycles: 0x, 
max_idle_ns: 12741736309 ns
[0.033158] Console: colour dummy device 80x30
[0.037694] Calibrating delay loop (skipped), value calculated using timer 
frequency.. 48.00 BogoMIPS (lpj=24)
[0.048136] pid_max: default: 32768 minimum: 301
[0.052914] Mount-cache hash table entries: 2048 (order: 1, 8192 bytes)
[0.059615] Mountpoint-cache hash table entries: 2048 (order: 1, 8192 bytes)
[0.067310] CPU: Testing write buffer coherency: ok
[0.072559] /cpus/cpu@0 missing clock-frequency property
[0.077954] /cpus/cpu@1 missing clock-frequency property
[0.083371] /cpus/cpu@2 missing clock-frequency property
[0.088765] /cpus/cpu@3 missing clock-frequency property
[0.094168] CPU0: thread -1, cpu 0, socket 0, mpidr 8000
[0.100072] Setting up static identity map for 0x4010 - 0x40100058
[0.119023] CPU1: thread -1, cpu 1, socket 0, mpidr 8001
[0.130609] CPU2: thread -1, 

[linux-sunxi] Re: [PATCH 01/14] dma: sun6i-dma: Add burst case of 4

2016-10-04 Thread Jean-Francois Moine
On Tue, 4 Oct 2016 14:12:21 +0200
Thomas Petazzoni  wrote:

> > > Add the case of a burst of 4 which is handled by the SoC.
> > > 
> > > Signed-off-by: Mylène Josserand 
> > > ---
> > >  drivers/dma/sun6i-dma.c | 2 ++
> > >  1 file changed, 2 insertions(+)
> > > 
> > > diff --git a/drivers/dma/sun6i-dma.c b/drivers/dma/sun6i-dma.c
> > > index 8346199..0485204 100644
> > > --- a/drivers/dma/sun6i-dma.c
> > > +++ b/drivers/dma/sun6i-dma.c
> > > @@ -240,6 +240,8 @@ static inline s8 convert_burst(u32 maxburst)
> > >   switch (maxburst) {
> > >   case 1:
> > >   return 0;
> > > + case 4:
> > > + return 1;
> > >   case 8:
> > >   return 2;
> > >   default:
> > > -- 
> > > 2.9.3  
> > 
> > This patch has already been rejected by Maxime in the threads
> > http://www.spinics.net/lists/dmaengine/msg08610.html
> > and
> > http://www.spinics.net/lists/dmaengine/msg08719.html
> > 
> > I hope you will find the way he wants for this maxburst to be added.
> 
> I was about to reply to Mylene's e-mail, suggesting that she should add
> a comment in the code (and maybe in the commit log) to explain why this
> addition is needed, and also that even though the schematics say that
> value "1" (max burst size of 4 bytes) is reserved, it is in fact
> incorrect. The Allwinner BSP code is really using this value, and it's
> the value that makes audio work, so we believe the datasheet is simply
> incorrect.
> 
> We already discussed it with Maxime, so I believe he should agree this
> time. But I would suggest to have such details explained in the commit
> log and in a comment in the code.

Strange. Looking at the datasheets of the A23, A31, A33, A83T and H3
(these are the SoCs using the DMA sun6i), only the H3 can have 4 as the
burst size (the doc is unclear for the A31).

Well, I was submitting for the H3, Mylène is submitting for the A33.
So, what about the A23, A31 and A83T?

-- 
Ken ar c'hentañ | ** Breizh ha Linux atav! **
Jef |   http://moinejf.free.fr/

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] Re: [PATCH 06/14] ASoC: Add sun8i digital audio codec

2016-10-04 Thread Mark Brown
On Tue, Oct 04, 2016 at 02:40:08PM +0200, Thomas Petazzoni wrote:

> > +/* CODEC_OFFSET represents the offset of the codec registers
> > + * and not all the DAI registers
> > + */

> This is not the proper comment style I believe for audio code, it
> should be:

> /*
>  * ...
>  */

I don't care, IIRC that's something from CodingStyle which checkpatch
moans about.

> > +   /* pcm operations */
> > +   .ops = _codec_dai_ops,
> > +};
> > +EXPORT_SYMBOL(sun8i_codec_dai);

> This EXPORT_SYMBOL looks wrong. First because it doesn't seem to be
> used outside of this module. And second because using EXPORT_SYMBOL on
> a function defined as static doesn't make much sense, as the "static"
> qualifier limits the visibility of the symbol to the current
> compilation unit.

Also all the ASoC code is _GPL so a non-GPL export is an issue.

> > +   .component_driver = {
> > +   .dapm_widgets   = sun8i_codec_dapm_widgets,
> > +   .num_dapm_widgets   = ARRAY_SIZE(sun8i_codec_dapm_widgets),
> > +   .dapm_routes= sun8i_codec_dapm_routes,
> > +   .num_dapm_routes= ARRAY_SIZE(sun8i_codec_dapm_routes),

> I'm probably missing something, but in the sun4i-codec.c driver, those
> fields are initialized directly in the snd_soc_codec_driver structure,
> not in the .component_driver sub-structure.

We're in the process of pushing everything out to component level, this
update should be made in the old code if it's not happened already.

> > +   if (clk_prepare_enable(scodec->clk_module))
> > +   pr_err("err:open failed;\n");

> Grr, pr_err, not good. Plus you want to return with an error from the
> probe() function.

Also when printing an error message use dev_err().

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: PGP signature


[linux-sunxi] Re: [PATCH 03/14] ASoC: sun4i-i2s: Add apb reset

2016-10-04 Thread Code Kipper
On 4 October 2016 at 11:46, Mylène Josserand
 wrote:
> Add APB deassert function for sun4i-i2s driver.
>
> Signed-off-by: Mylène Josserand 
> ---
>  sound/soc/sunxi/sun4i-i2s.c | 16 +++-
>  1 file changed, 15 insertions(+), 1 deletion(-)
>
> diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c
> index 687a8f8..f3f7026 100644
> --- a/sound/soc/sunxi/sun4i-i2s.c
> +++ b/sound/soc/sunxi/sun4i-i2s.c
> @@ -17,6 +17,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>
>  #include 
>  #include 
> @@ -589,6 +590,7 @@ static int sun4i_i2s_probe(struct platform_device *pdev)
>  {
> struct sun4i_i2s *i2s;
> struct resource *res;
> +   struct reset_control *reset_apb;
> void __iomem *regs;
> int irq, ret;
>
> @@ -626,7 +628,19 @@ static int sun4i_i2s_probe(struct platform_device *pdev)
> dev_err(>dev, "Can't get our mod clock\n");
> return PTR_ERR(i2s->mod_clk);
> }
> -
> +
> +   reset_apb = devm_reset_control_get(>dev, "apb_reset");
> +   if (IS_ERR(reset_apb)) {
> +   dev_err(>dev, "Can't get apb reset\n");
> +   return PTR_ERR(i2s->mod_clk);
> +   }
> +
> +   ret = reset_control_deassert(reset_apb);
> +   if (ret < 0) {
> +   dev_err(>dev, "Can't deassert apb reset (%d)\n", ret);
> +   return ret;
> +   }
> +
Is this functionality only required for A31 and onwards?,
CK
> i2s->playback_dma_data.addr = res->start + SUN4I_I2S_FIFO_TX_REG;
> i2s->playback_dma_data.maxburst = 4;
>
> --
> 2.9.3
>
>
> ___
> linux-arm-kernel mailing list
> linux-arm-ker...@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] Re: [PATCH 07/14] ASoC: Add sun8i audio card

2016-10-04 Thread Chen-Yu Tsai
On Tue, Oct 4, 2016 at 6:16 PM, Code Kipper  wrote:
> On 4 October 2016 at 11:46, Mylène Josserand
>  wrote:
>> Add the audio card for sun8i SoC. This card links the codec driver
>> (digital part) with the DAI driver. The analog codec driver is
>> added as an aux_device.
>>
>> Signed-off-by: Mylène Josserand 
>> ---
>>  sound/soc/sunxi/Kconfig  |  14 +++
>>  sound/soc/sunxi/Makefile |   1 +
>>  sound/soc/sunxi/sun8i.c  | 101 
>> +++
>>  3 files changed, 116 insertions(+)
>>  create mode 100644 sound/soc/sunxi/sun8i.c
>>
>> diff --git a/sound/soc/sunxi/Kconfig b/sound/soc/sunxi/Kconfig
>> index 9e287b0..7b97395 100644
>> --- a/sound/soc/sunxi/Kconfig
>> +++ b/sound/soc/sunxi/Kconfig
>> @@ -27,6 +27,20 @@ config SND_SUN4I_SPDIF
>>   Say Y or M to add support for the S/PDIF audio block in the 
>> Allwinner
>>   A10 and affiliated SoCs.
>>
>> +config SND_SUN8I
>> +   tristate "Allwinner SUN6I/SUN8I audio card support"
>> +   select SND_SUN8I_CODEC
>> +   select SND_SUN4I_I2S
>> +   select SND_SUN8I_CODEC_ANALOG
>> +   select REGMAP_MMIO
>> +   help
>> + This option enables the audio card for Allwinner A33 (sun8i) SoC.
>> + It enables the DAI driver (SND_SUN4I_I2S), the digital audio
>> + codec driver (SND_SUN8I_CODEC) and the analog codec driver
>> + (SND_SUN8I_CODEC_ANALOG).
>> +
>> + Say Y or M if you want to add sun8i/6i card support
>> +
>>  config SND_SUN8I_CODEC
>> tristate "Allwinner SUN8I audio codec"
>> select REGMAP_MMIO
>> diff --git a/sound/soc/sunxi/Makefile b/sound/soc/sunxi/Makefile
>> index 1da63d3..7f1bab9 100644
>> --- a/sound/soc/sunxi/Makefile
>> +++ b/sound/soc/sunxi/Makefile
>> @@ -1,5 +1,6 @@
>>  obj-$(CONFIG_SND_SUN4I_CODEC) += sun4i-codec.o
>>  obj-$(CONFIG_SND_SUN4I_I2S) += sun4i-i2s.o
>>  obj-$(CONFIG_SND_SUN4I_SPDIF) += sun4i-spdif.o
>> +obj-$(CONFIG_SND_SUN8I) += sun8i.o
> Great work with this...I've been battling with the audio codec for the
> h3 for a while and it looks like almost everything that I need is
> delivered here.
>>  obj-$(CONFIG_SND_SUN8I_CODEC) += sun8i-codec.o
>>  obj-$(CONFIG_SND_SUN8I_CODEC_ANALOG) += sun8i-codec-analog.o
>> diff --git a/sound/soc/sunxi/sun8i.c b/sound/soc/sunxi/sun8i.c
>> new file mode 100644
>> index 000..565cd88
>> --- /dev/null
>> +++ b/sound/soc/sunxi/sun8i.c
>> @@ -0,0 +1,101 @@
>> +/*
>> + * ALSA SoC driver for Allwinner sun8i SoC
>> + *
>> + * Copyright (C) 2016 Mylène Josserand 
>> + *
>> + * 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.
>> + *
>> + * This program is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>> + * GNU General Public License for more details.
>> + */
>> +
>> +#include 
>> +#include 
>> +
>> +#include 
>> +
>> +static struct snd_soc_aux_dev sun8i_audio_prcm_aux_devs[] = {
>> +   {
>> +   .name = "sun8i-codec-analog",
>> +   .codec_name = "sun8i-codec-analog.0",
>> +   },
>> +};
>> +
>> +static struct snd_soc_dai_link sun8i_dai_link = {
>> +   .name   = "sun4i-i2s",
>> +   .stream_name= "Playback",
>> +   .codec_dai_name = "sun8i",
>> +   .dai_fmt= SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_I2S |
>> +   SND_SOC_DAIFMT_CBM_CFM,
>> +};
>> +
>> +static struct snd_soc_card sun8i_card = {
>> +   .name   = "sun8i-card",
>> +   .owner  = THIS_MODULE,
>> +   .dai_link   = _dai_link,
>> +   .num_links  = 1,
>> +   .aux_dev= sun8i_audio_prcm_aux_devs,
>> +   .num_aux_devs   = ARRAY_SIZE(sun8i_audio_prcm_aux_devs),
>> +};
>> +
>> +static int sun8i_probe(struct platform_device *pdev)
>> +{
>> +   struct snd_soc_dai_link *link = _dai_link;
>> +   struct device_node *np = pdev->dev.of_node;
>> +   int ret;
>> +
>> +   /* register the soc card */
>> +   sun8i_card.dev = >dev;
>> +
>> +   /* Retrieve the audio-codec from DT */
>> +   link->codec_of_node = of_parse_phandle(np, "allwinner,audio-codec", 
>> 0);
>> +   if (!link->codec_of_node) {
>> +   dev_err(>dev, "Missing audio codec\n");
>> +   return -EINVAL;
>> +   }
>> +
>> +   /* Retrieve DAI from DT */
>> +   link->cpu_of_node = of_parse_phandle(np, "allwinner,i2s-controller", 
>> 0);
>> +   if (!link->cpu_of_node) {
>> +   dev_err(>dev, "Missing I2S controller\n");
>> +   return -EINVAL;
>> +   }
>> +
> My one 

[linux-sunxi] Re: [PATCH 04/14] ASoC: Add sun8i analog codec driver

2016-10-04 Thread Chen-Yu Tsai
On Tue, Oct 4, 2016 at 6:21 PM, Code Kipper  wrote:
> On 4 October 2016 at 11:46, Mylène Josserand
>  wrote:
>> Add the analog part of the sun8i (A33) codec driver. This driver
>> implements all the analog part of the codec using PRCM registers.
>>
>> The read/write regmap functions must be handled in a custom way as
>> the PRCM register behaves as "mailbox" register.
>>
>> Signed-off-by: Mylène Josserand 
>> ---
>>  sound/soc/sunxi/Kconfig  |   7 +
>>  sound/soc/sunxi/Makefile |   1 +
>>  sound/soc/sunxi/sun8i-codec-analog.c | 304 
>> +++
>>  3 files changed, 312 insertions(+)
>>  create mode 100644 sound/soc/sunxi/sun8i-codec-analog.c
>>
>> diff --git a/sound/soc/sunxi/Kconfig b/sound/soc/sunxi/Kconfig
>> index dd23682..7aee95a 100644
>> --- a/sound/soc/sunxi/Kconfig
>> +++ b/sound/soc/sunxi/Kconfig
>> @@ -26,4 +26,11 @@ config SND_SUN4I_SPDIF
>> help
>>   Say Y or M to add support for the S/PDIF audio block in the 
>> Allwinner
>>   A10 and affiliated SoCs.
>> +
>> +config SND_SUN8I_CODEC_ANALOG
>> +   tristate "Allwinner SUN8I analog codec"
>> +   select REGMAP_MMIO
>> +help
>> + Say Y or M if you want to add sun8i analog audiocodec support
>> +
>>  endmenu
>> diff --git a/sound/soc/sunxi/Makefile b/sound/soc/sunxi/Makefile
>> index 604c7b84..241c0df 100644
>> --- a/sound/soc/sunxi/Makefile
>> +++ b/sound/soc/sunxi/Makefile
>> @@ -1,3 +1,4 @@
>>  obj-$(CONFIG_SND_SUN4I_CODEC) += sun4i-codec.o
>>  obj-$(CONFIG_SND_SUN4I_I2S) += sun4i-i2s.o
>>  obj-$(CONFIG_SND_SUN4I_SPDIF) += sun4i-spdif.o
>> +obj-$(CONFIG_SND_SUN8I_CODEC_ANALOG) += sun8i-codec-analog.o
>> diff --git a/sound/soc/sunxi/sun8i-codec-analog.c 
>> b/sound/soc/sunxi/sun8i-codec-analog.c
>> new file mode 100644
>> index 000..be3d540
>> --- /dev/null
>> +++ b/sound/soc/sunxi/sun8i-codec-analog.c
>> @@ -0,0 +1,304 @@
>> +/*
>> + * This driver supports the analog controls for the internal codec
>> + * found in Allwinner's A31s, A33 and A23 SoCs.
>> + *
>> + * Copyright 2016 Chen-Yu Tsai 
>> + * Copyright 2016 Mylène Josserand 
>> + *
>> + * 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.
>> + *
>> + * This program is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>> + * GNU General Public License for more details.
>> + */
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +#include 
>> +#include 
>> +#include 
>> +
>> +/* Codec analog control register offsets and bit fields */
>> +#define SUN8I_ADDA_HP_VOLC 0x00
>> +#define SUN8I_ADDA_HP_VOLC_PA_CLK_GATE 7
>> +#define SUN8I_ADDA_HP_VOLC_HP_VOL  0
>> +#define SUN8I_ADDA_LOMIXSC 0x01
>> +#define SUN8I_ADDA_LOMIXSC_MIC16
>> +#define SUN8I_ADDA_LOMIXSC_MIC25
>> +#define SUN8I_ADDA_LOMIXSC_PHONE   4
>> +#define SUN8I_ADDA_LOMIXSC_PHONEN  3
>> +#define SUN8I_ADDA_LOMIXSC_LINEINL 2
>> +#define SUN8I_ADDA_LOMIXSC_DACL1
>> +#define SUN8I_ADDA_LOMIXSC_DACR0
>> +#define SUN8I_ADDA_ROMIXSC 0x02
>> +#define SUN8I_ADDA_ROMIXSC_MIC16
>> +#define SUN8I_ADDA_ROMIXSC_MIC25
>> +#define SUN8I_ADDA_ROMIXSC_PHONE   4
>> +#define SUN8I_ADDA_ROMIXSC_PHONEP  3
>> +#define SUN8I_ADDA_ROMIXSC_LINEINR 2
>> +#define SUN8I_ADDA_ROMIXSC_DACR1
>> +#define SUN8I_ADDA_ROMIXSC_DACL0
>> +#define SUN8I_ADDA_DAC_PA_SRC  0x03
>> +#define SUN8I_ADDA_DAC_PA_SRC_DACAREN  7
>> +#define SUN8I_ADDA_DAC_PA_SRC_DACALEN  6
>> +#define SUN8I_ADDA_DAC_PA_SRC_RMIXEN   5
>> +#define SUN8I_ADDA_DAC_PA_SRC_LMIXEN   4
>> +#define SUN8I_ADDA_DAC_PA_SRC_RHPPAMUTE3
>> +#define SUN8I_ADDA_DAC_PA_SRC_LHPPAMUTE2
>> +#define SUN8I_ADDA_DAC_PA_SRC_RHPIS1
>> +#define SUN8I_ADDA_DAC_PA_SRC_LHPIS0
>> +#define SUN8I_ADDA_PHONEIN_GCTRL   0x04
>> +#define SUN8I_ADDA_PHONEIN_GCTRL_PHONEPG   4
>> +#define SUN8I_ADDA_PHONEIN_GCTRL_PHONENG   0
>> +#define SUN8I_ADDA_LINEIN_GCTRL0x05
>> +#define 

[linux-sunxi] Re: [PATCH 05/14] mfd: sun6i-prcm: Add sun8i analog codec as subnode

2016-10-04 Thread Jean-Francois Moine
On Tue,  4 Oct 2016 11:46:18 +0200
Mylène Josserand  wrote:

> The sun8i audio codec is using PRCM registers to configure all the
> analog part of the audio codec. It is added as a subnode of the PRCM
> with his resource (offset of 0x1c0).
> 
> Signed-off-by: Mylène Josserand 
> ---
>  drivers/mfd/sun6i-prcm.c | 16 
>  1 file changed, 16 insertions(+)
[snip]

I was heard that the PRCM as a MFD would disappear.

-- 
Ken ar c'hentañ | ** Breizh ha Linux atav! **
Jef |   http://moinejf.free.fr/

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] Re: [PATCH 01/14] dma: sun6i-dma: Add burst case of 4

2016-10-04 Thread Jean-Francois Moine
On Tue,  4 Oct 2016 11:46:14 +0200
Mylène Josserand  wrote:

> Add the case of a burst of 4 which is handled by the SoC.
> 
> Signed-off-by: Mylène Josserand 
> ---
>  drivers/dma/sun6i-dma.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/dma/sun6i-dma.c b/drivers/dma/sun6i-dma.c
> index 8346199..0485204 100644
> --- a/drivers/dma/sun6i-dma.c
> +++ b/drivers/dma/sun6i-dma.c
> @@ -240,6 +240,8 @@ static inline s8 convert_burst(u32 maxburst)
>   switch (maxburst) {
>   case 1:
>   return 0;
> + case 4:
> + return 1;
>   case 8:
>   return 2;
>   default:
> -- 
> 2.9.3

This patch has already been rejected by Maxime in the threads
http://www.spinics.net/lists/dmaengine/msg08610.html
and
http://www.spinics.net/lists/dmaengine/msg08719.html

I hope you will find the way he wants for this maxburst to be added.

-- 
Ken ar c'hentañ | ** Breizh ha Linux atav! **
Jef |   http://moinejf.free.fr/

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] Re: [PATCH 08/14] dt-bindings: sound: Add sun8i analog codec documentation

2016-10-04 Thread Mark Brown
On Tue, Oct 04, 2016 at 11:46:21AM +0200, Mylène Josserand wrote:

> +* Allwinner A23/A33 Analog Codec
> +
> +This codec must be handled as a PRCM subnode.

What does this mean - how does one handle something as a "PRCM subnode"?

Please use subject lines matching the style for the subsystem.  This
makes it easier for people to identify relevant patches.

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: PGP signature


[linux-sunxi] Re: [PATCH 04/14] ASoC: Add sun8i analog codec driver

2016-10-04 Thread Code Kipper
On 4 October 2016 at 11:46, Mylène Josserand
 wrote:
> Add the analog part of the sun8i (A33) codec driver. This driver
> implements all the analog part of the codec using PRCM registers.
>
> The read/write regmap functions must be handled in a custom way as
> the PRCM register behaves as "mailbox" register.
>
> Signed-off-by: Mylène Josserand 
> ---
>  sound/soc/sunxi/Kconfig  |   7 +
>  sound/soc/sunxi/Makefile |   1 +
>  sound/soc/sunxi/sun8i-codec-analog.c | 304 
> +++
>  3 files changed, 312 insertions(+)
>  create mode 100644 sound/soc/sunxi/sun8i-codec-analog.c
>
> diff --git a/sound/soc/sunxi/Kconfig b/sound/soc/sunxi/Kconfig
> index dd23682..7aee95a 100644
> --- a/sound/soc/sunxi/Kconfig
> +++ b/sound/soc/sunxi/Kconfig
> @@ -26,4 +26,11 @@ config SND_SUN4I_SPDIF
> help
>   Say Y or M to add support for the S/PDIF audio block in the 
> Allwinner
>   A10 and affiliated SoCs.
> +
> +config SND_SUN8I_CODEC_ANALOG
> +   tristate "Allwinner SUN8I analog codec"
> +   select REGMAP_MMIO
> +help
> + Say Y or M if you want to add sun8i analog audiocodec support
> +
>  endmenu
> diff --git a/sound/soc/sunxi/Makefile b/sound/soc/sunxi/Makefile
> index 604c7b84..241c0df 100644
> --- a/sound/soc/sunxi/Makefile
> +++ b/sound/soc/sunxi/Makefile
> @@ -1,3 +1,4 @@
>  obj-$(CONFIG_SND_SUN4I_CODEC) += sun4i-codec.o
>  obj-$(CONFIG_SND_SUN4I_I2S) += sun4i-i2s.o
>  obj-$(CONFIG_SND_SUN4I_SPDIF) += sun4i-spdif.o
> +obj-$(CONFIG_SND_SUN8I_CODEC_ANALOG) += sun8i-codec-analog.o
> diff --git a/sound/soc/sunxi/sun8i-codec-analog.c 
> b/sound/soc/sunxi/sun8i-codec-analog.c
> new file mode 100644
> index 000..be3d540
> --- /dev/null
> +++ b/sound/soc/sunxi/sun8i-codec-analog.c
> @@ -0,0 +1,304 @@
> +/*
> + * This driver supports the analog controls for the internal codec
> + * found in Allwinner's A31s, A33 and A23 SoCs.
> + *
> + * Copyright 2016 Chen-Yu Tsai 
> + * Copyright 2016 Mylène Josserand 
> + *
> + * 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.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +#include 
> +#include 
> +
> +/* Codec analog control register offsets and bit fields */
> +#define SUN8I_ADDA_HP_VOLC 0x00
> +#define SUN8I_ADDA_HP_VOLC_PA_CLK_GATE 7
> +#define SUN8I_ADDA_HP_VOLC_HP_VOL  0
> +#define SUN8I_ADDA_LOMIXSC 0x01
> +#define SUN8I_ADDA_LOMIXSC_MIC16
> +#define SUN8I_ADDA_LOMIXSC_MIC25
> +#define SUN8I_ADDA_LOMIXSC_PHONE   4
> +#define SUN8I_ADDA_LOMIXSC_PHONEN  3
> +#define SUN8I_ADDA_LOMIXSC_LINEINL 2
> +#define SUN8I_ADDA_LOMIXSC_DACL1
> +#define SUN8I_ADDA_LOMIXSC_DACR0
> +#define SUN8I_ADDA_ROMIXSC 0x02
> +#define SUN8I_ADDA_ROMIXSC_MIC16
> +#define SUN8I_ADDA_ROMIXSC_MIC25
> +#define SUN8I_ADDA_ROMIXSC_PHONE   4
> +#define SUN8I_ADDA_ROMIXSC_PHONEP  3
> +#define SUN8I_ADDA_ROMIXSC_LINEINR 2
> +#define SUN8I_ADDA_ROMIXSC_DACR1
> +#define SUN8I_ADDA_ROMIXSC_DACL0
> +#define SUN8I_ADDA_DAC_PA_SRC  0x03
> +#define SUN8I_ADDA_DAC_PA_SRC_DACAREN  7
> +#define SUN8I_ADDA_DAC_PA_SRC_DACALEN  6
> +#define SUN8I_ADDA_DAC_PA_SRC_RMIXEN   5
> +#define SUN8I_ADDA_DAC_PA_SRC_LMIXEN   4
> +#define SUN8I_ADDA_DAC_PA_SRC_RHPPAMUTE3
> +#define SUN8I_ADDA_DAC_PA_SRC_LHPPAMUTE2
> +#define SUN8I_ADDA_DAC_PA_SRC_RHPIS1
> +#define SUN8I_ADDA_DAC_PA_SRC_LHPIS0
> +#define SUN8I_ADDA_PHONEIN_GCTRL   0x04
> +#define SUN8I_ADDA_PHONEIN_GCTRL_PHONEPG   4
> +#define SUN8I_ADDA_PHONEIN_GCTRL_PHONENG   0
> +#define SUN8I_ADDA_LINEIN_GCTRL0x05
> +#define SUN8I_ADDA_LINEIN_GCTRL_LINEING4
> +#define SUN8I_ADDA_LINEIN_GCTRL_PHONEG 0
> +#define SUN8I_ADDA_MICIN_GCTRL 0x06
> +#define 

[linux-sunxi] Re: [PATCH 07/14] ASoC: Add sun8i audio card

2016-10-04 Thread Code Kipper
On 4 October 2016 at 11:46, Mylène Josserand
 wrote:
> Add the audio card for sun8i SoC. This card links the codec driver
> (digital part) with the DAI driver. The analog codec driver is
> added as an aux_device.
>
> Signed-off-by: Mylène Josserand 
> ---
>  sound/soc/sunxi/Kconfig  |  14 +++
>  sound/soc/sunxi/Makefile |   1 +
>  sound/soc/sunxi/sun8i.c  | 101 
> +++
>  3 files changed, 116 insertions(+)
>  create mode 100644 sound/soc/sunxi/sun8i.c
>
> diff --git a/sound/soc/sunxi/Kconfig b/sound/soc/sunxi/Kconfig
> index 9e287b0..7b97395 100644
> --- a/sound/soc/sunxi/Kconfig
> +++ b/sound/soc/sunxi/Kconfig
> @@ -27,6 +27,20 @@ config SND_SUN4I_SPDIF
>   Say Y or M to add support for the S/PDIF audio block in the 
> Allwinner
>   A10 and affiliated SoCs.
>
> +config SND_SUN8I
> +   tristate "Allwinner SUN6I/SUN8I audio card support"
> +   select SND_SUN8I_CODEC
> +   select SND_SUN4I_I2S
> +   select SND_SUN8I_CODEC_ANALOG
> +   select REGMAP_MMIO
> +   help
> + This option enables the audio card for Allwinner A33 (sun8i) SoC.
> + It enables the DAI driver (SND_SUN4I_I2S), the digital audio
> + codec driver (SND_SUN8I_CODEC) and the analog codec driver
> + (SND_SUN8I_CODEC_ANALOG).
> +
> + Say Y or M if you want to add sun8i/6i card support
> +
>  config SND_SUN8I_CODEC
> tristate "Allwinner SUN8I audio codec"
> select REGMAP_MMIO
> diff --git a/sound/soc/sunxi/Makefile b/sound/soc/sunxi/Makefile
> index 1da63d3..7f1bab9 100644
> --- a/sound/soc/sunxi/Makefile
> +++ b/sound/soc/sunxi/Makefile
> @@ -1,5 +1,6 @@
>  obj-$(CONFIG_SND_SUN4I_CODEC) += sun4i-codec.o
>  obj-$(CONFIG_SND_SUN4I_I2S) += sun4i-i2s.o
>  obj-$(CONFIG_SND_SUN4I_SPDIF) += sun4i-spdif.o
> +obj-$(CONFIG_SND_SUN8I) += sun8i.o
Great work with this...I've been battling with the audio codec for the
h3 for a while and it looks like almost everything that I need is
delivered here.
>  obj-$(CONFIG_SND_SUN8I_CODEC) += sun8i-codec.o
>  obj-$(CONFIG_SND_SUN8I_CODEC_ANALOG) += sun8i-codec-analog.o
> diff --git a/sound/soc/sunxi/sun8i.c b/sound/soc/sunxi/sun8i.c
> new file mode 100644
> index 000..565cd88
> --- /dev/null
> +++ b/sound/soc/sunxi/sun8i.c
> @@ -0,0 +1,101 @@
> +/*
> + * ALSA SoC driver for Allwinner sun8i SoC
> + *
> + * Copyright (C) 2016 Mylène Josserand 
> + *
> + * 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.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + */
> +
> +#include 
> +#include 
> +
> +#include 
> +
> +static struct snd_soc_aux_dev sun8i_audio_prcm_aux_devs[] = {
> +   {
> +   .name = "sun8i-codec-analog",
> +   .codec_name = "sun8i-codec-analog.0",
> +   },
> +};
> +
> +static struct snd_soc_dai_link sun8i_dai_link = {
> +   .name   = "sun4i-i2s",
> +   .stream_name= "Playback",
> +   .codec_dai_name = "sun8i",
> +   .dai_fmt= SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_I2S |
> +   SND_SOC_DAIFMT_CBM_CFM,
> +};
> +
> +static struct snd_soc_card sun8i_card = {
> +   .name   = "sun8i-card",
> +   .owner  = THIS_MODULE,
> +   .dai_link   = _dai_link,
> +   .num_links  = 1,
> +   .aux_dev= sun8i_audio_prcm_aux_devs,
> +   .num_aux_devs   = ARRAY_SIZE(sun8i_audio_prcm_aux_devs),
> +};
> +
> +static int sun8i_probe(struct platform_device *pdev)
> +{
> +   struct snd_soc_dai_link *link = _dai_link;
> +   struct device_node *np = pdev->dev.of_node;
> +   int ret;
> +
> +   /* register the soc card */
> +   sun8i_card.dev = >dev;
> +
> +   /* Retrieve the audio-codec from DT */
> +   link->codec_of_node = of_parse_phandle(np, "allwinner,audio-codec", 
> 0);
> +   if (!link->codec_of_node) {
> +   dev_err(>dev, "Missing audio codec\n");
> +   return -EINVAL;
> +   }
> +
> +   /* Retrieve DAI from DT */
> +   link->cpu_of_node = of_parse_phandle(np, "allwinner,i2s-controller", 
> 0);
> +   if (!link->cpu_of_node) {
> +   dev_err(>dev, "Missing I2S controller\n");
> +   return -EINVAL;
> +   }
> +
My one question is that we have sun8i-a23 and sun8i-a33, and I think
we need to distinguish them here. The sun8i-a23 doesn't use the i2s
block but does use the prcm.
> +   link->platform_of_node = link->cpu_of_node;
> +
>