Re: [PATCH] clk/arc: Add I2S PLL clock driver

2016-03-31 Thread Vineet Gupta
On Tuesday 29 March 2016 11:21 PM, Jose Abreu wrote:

Well, this was just an experiment and I think this patch is still far from being
ready to go mainline, that's why I did not cc'ed the clk maintainers. I will
send a v2 soon so you can review and if you think its worth sending to mainline
I will do that.


It never hurts to CC actual maintainer as they will be able to provide you the 
best feedback.
Each of us have our domain expertise so I may review your code superficially 
but only the person who knows the subsystem inside-out can tell you exactly 
what to do.

They are grumpy at times and might bitch a bit but as they they "it is your 
code that gets criticized - not you"
I've learnt this myself over the years :-)

-Vineet

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH 2/3 v2] ASoC: dwc: Add I2S HDMI audio support

2016-03-31 Thread Jose Abreu
Hi Mark,

On 29-03-2016 19:22, Mark Brown wrote:
> On Tue, Mar 29, 2016 at 07:03:01PM +0100, Jose Abreu wrote:
>
>> The major part of this patch is the adding of an ALSA platform driver so that
>> audio comes out of the box in AXS boards but we also added functionalities to
>> the i2s driver and performed one bug fix related with the mask/unmask of
>> interrupts. I will split the patches but they will depend on each other.
> If you want to add a new platform driver you need to add a new platform
> driver, not shove the code into an existing driver for a seperate IP.
>

I can separate the platform driver into a new file but they will have to be
compiled into the same module as the new additions to the i2s driver depend on
functions of the platform driver (see i2s_irq_handler()). Or should I divide
this into two modules and add a Kconfig option to the platform driver? Besides
this I first wanted the driver to be compiled into the same module so that it is
compatible with kernel 3.18 where simple audio card requires that platform
driver == cpu driver.

Best regards,
Jose Miguel Abreu

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH 1/3 v2] drm/i2c/adv7511: Add audio support

2016-03-31 Thread Jose Abreu
Hi Archit,


On 29-03-2016 18:03, Archit Taneja wrote:
>
>
> On 3/29/2016 4:22 PM, Jose Abreu wrote:
>> Hi Archit,
>>
>> On 29-03-2016 09:05, Archit Taneja wrote:
>>> Hi,
>>>
>>> On 03/28/2016 08:06 PM, Jose Abreu wrote:
 This patch adds audio support for the ADV7511 HDMI transmitter
 using ALSA SoC.

 The code was ported from Analog Devices linux tree from
 commit 1770c4a1e32b ("Merge remote-tracking branch
 'xilinx/master' into xcomm_zynq"), which is available at:
  - https://github.com/analogdevicesinc/linux/

 The main core file was renamed from adv7511.c to adv7511_core.c
 so that audio and video compile into a single adv7511.ko module
 and to keep up with Analog Devices kernel tree.

 The audio can be disabled using menu-config so it is possible
 to use only video mode.

 The HDMI mode is automatically started at boot and the audio
 (when enabled) registers as a codec into ALSA.
>>>
>>> Is there a reason why we set the mode to HDMI at probe itself?
>>> Shouldn't it be okay to set the mode later once we read the
>>> EDID off the panel?
>>>
>>> Some more comments below.
>>>
>>
>> Well, when I was using this in kernel 3.18 (with an older version of the 
>> driver)
>> I noticed that DVI mode was being used even when HDMI was connected so I 
>> forced
>> the driver to start in HDMI mode. There were some changes in the driver so 
>> it is
>> possible that this is no longer needed. Should I drop it?
>
> Mode selection works fine with ADV7533 on a 4.5 kernel. I'm assuming it
> should work out of the box for ADV7511 too. We should drop this.
>
>

Ok, will drop.

>>

 SPDIF DAI format was also added to ASoC as it is required
 by adv7511 audio.

 Signed-off-by: Jose Abreu 
 ---

 No changes v1 -> v2.

drivers/gpu/drm/i2c/Kconfig |   11 +
drivers/gpu/drm/i2c/Makefile|2 +
drivers/gpu/drm/i2c/adv7511.c   | 1024
 ---
drivers/gpu/drm/i2c/adv7511.h   |   41 ++
drivers/gpu/drm/i2c/adv7511_audio.c |  310 +++
drivers/gpu/drm/i2c/adv7511_core.c  | 1005
 ++
include/sound/soc-dai.h |1 +
7 files changed, 1370 insertions(+), 1024 deletions(-)
delete mode 100644 drivers/gpu/drm/i2c/adv7511.c
create mode 100644 drivers/gpu/drm/i2c/adv7511_audio.c
create mode 100644 drivers/gpu/drm/i2c/adv7511_core.c
>>>
>>> 
>>>
 +
 +static int adv7511_probe(struct i2c_client *i2c, const struct 
 i2c_device_id
 *id)
 +{
 +struct adv7511_link_config link_config;
 +struct adv7511 *adv7511;
 +struct device *dev = &i2c->dev;
 +unsigned int val;
 +int ret;
 +
 +if (!dev->of_node)
 +return -EINVAL;
 +
 +adv7511 = devm_kzalloc(dev, sizeof(*adv7511), GFP_KERNEL);
 +if (!adv7511)
 +return -ENOMEM;
 +
 +adv7511->powered = false;
 +adv7511->status = connector_status_disconnected;
 +
 +ret = adv7511_parse_dt(dev->of_node, &link_config);
 +if (ret)
 +return ret;
 +
 +/*
 + * The power down GPIO is optional. If present, toggle it from active 
 to
 + * inactive to wake up the encoder.
 + */
 +adv7511->gpio_pd = devm_gpiod_get_optional(dev, "pd", GPIOD_OUT_HIGH);
 +if (IS_ERR(adv7511->gpio_pd))
 +return PTR_ERR(adv7511->gpio_pd);
 +
 +if (adv7511->gpio_pd) {
 +mdelay(5);
 +gpiod_set_value_cansleep(adv7511->gpio_pd, 0);
 +}
 +
 +adv7511->regmap = devm_regmap_init_i2c(i2c, &adv7511_regmap_config);
 +if (IS_ERR(adv7511->regmap))
 +return PTR_ERR(adv7511->regmap);
 +
 +ret = regmap_read(adv7511->regmap, ADV7511_REG_CHIP_REVISION, &val);
 +if (ret)
 +return ret;
 +dev_dbg(dev, "Rev. %d\n", val);
 +
 +ret = regmap_register_patch(adv7511->regmap, adv7511_fixed_registers,
 +ARRAY_SIZE(adv7511_fixed_registers));
 +if (ret)
 +return ret;
 +
 +regmap_write(adv7511->regmap, ADV7511_REG_EDID_I2C_ADDR, 
 edid_i2c_addr);
 +regmap_write(adv7511->regmap, ADV7511_REG_PACKET_I2C_ADDR,
 + packet_i2c_addr);
 +regmap_write(adv7511->regmap, ADV7511_REG_CEC_I2C_ADDR, cec_i2c_addr);
 +adv7511_packet_disable(adv7511, 0x);
 +
 +adv7511->i2c_main = i2c;
 +adv7511->i2c_edid = i2c_new_dummy(i2c->adapter, edid_i2c_addr >> 1);
 +if (!adv7511->i2c_edid)
 +return -ENOMEM;
 +
 +if (i2c->irq) {
 +init_waitqueue_head(&adv7511->wq);
 +
 +ret = devm_request_threaded_irq(dev, i2c->irq, NULL,
 +adv7511_irq_handler,
 

[PATCH v2 2/4] exit_thread: remove empty bodies

2016-03-31 Thread Jiri Slaby
Define HAVE_EXIT_THREAD for archs which want to do something in
exit_thread. For others, let's define exit_thread as an empty inline.

This is a cleanup before we change the prototype of exit_thread to
accept a task parameter.

Signed-off-by: Jiri Slaby 
Cc: Richard Henderson 
Cc: Ivan Kokshaysky 
Cc: Matt Turner 
Cc: Vineet Gupta 
Cc: Russell King 
Cc: Catalin Marinas 
Cc: Will Deacon 
Cc: Haavard Skinnemoen 
Cc: Hans-Christian Egtvedt 
Cc: Steven Miao 
Cc: Mark Salter 
Cc: Aurelien Jacquiot 
Cc: Mikael Starvik 
Cc: Jesper Nilsson 
Cc: Yoshinori Sato 
Cc: Richard Kuo 
Cc: Geert Uytterhoeven 
Cc: James Hogan 
Cc: Michal Simek 
Cc: Ralf Baechle 
Cc: David Howells 
Cc: Koichi Yasutake 
Cc: Ley Foon Tan 
Cc: Jonas Bonn 
Cc: "James E.J. Bottomley" 
Cc: Helge Deller 
Cc: Benjamin Herrenschmidt 
Cc: Paul Mackerras 
Cc: Michael Ellerman 
Cc: Martin Schwidefsky 
Cc: Heiko Carstens 
Cc: Chen Liqin 
Cc: Lennox Wu 
Cc: Rich Felker 
Cc: "David S. Miller" 
Cc: Chris Metcalf 
Cc: Jeff Dike 
Cc: Richard Weinberger 
Cc: Guan Xuetao 
Cc: Thomas Gleixner 
Cc: Ingo Molnar 
Cc: "H. Peter Anvin" 
Cc: x...@kernel.org
Cc: Tony Luck 
Cc: Fenghua Yu 
Cc: Chris Zankel 
Cc: Max Filippov 
Cc: Peter Zijlstra 
Cc: linux-ker...@vger.kernel.org
Cc: linux-al...@vger.kernel.org
Cc: linux-snps-arc@lists.infradead.org
Cc: linux-arm-ker...@lists.infradead.org
Cc: adi-buildroot-de...@lists.sourceforge.net
Cc: linux-c6x-...@linux-c6x.org
Cc: linux-cris-ker...@axis.com
Cc: linux-i...@vger.kernel.org
Cc: uclinux-h8-de...@lists.sourceforge.jp
Cc: linux-hexa...@vger.kernel.org
Cc: linux-m...@lists.linux-m68k.org
Cc: linux-me...@vger.kernel.org
Cc: linux-m...@linux-mips.org
Cc: linux-am33-l...@redhat.com
Cc: nios2-...@lists.rocketboards.org
Cc: linux-par...@vger.kernel.org
Cc: linuxppc-...@lists.ozlabs.org
Cc: linux-s...@vger.kernel.org
Cc: linux...@vger.kernel.org
Cc: sparcli...@vger.kernel.org
Cc: user-mode-linux-de...@lists.sourceforge.net
Cc: user-mode-linux-u...@lists.sourceforge.net
Cc: linux-xte...@linux-xtensa.org
---
 arch/Kconfig|  5 +
 arch/alpha/kernel/process.c |  8 
 arch/arc/kernel/process.c   |  7 ---
 arch/arm/Kconfig|  1 +
 arch/arm64/kernel/process.c |  7 ---
 arch/avr32/Kconfig  |  1 +
 arch/blackfin/include/asm/processor.h   |  7 ---
 arch/c6x/kernel/process.c   |  4 
 arch/cris/Kconfig   |  1 +
 arch/cris/arch-v10/kernel/process.c |  9 -
 arch/frv/include/asm/processor.h|  7 ---
 arch/h8300/include/asm/processor.h  |  7 ---
 arch/hexagon/kernel/process.c   |  7 ---
 arch/ia64/Kconfig   |  1 +
 arch/m32r/kernel/process.c  |  9 -
 arch/m68k/include/asm/processor.h   |  7 ---
 arch/metag/Kconfig  |  1 +
 arch/metag/include/asm/processor.h  |  2 --
 arch/microblaze/include/asm/processor.h | 10 --
 arch/mips/include/asm/processor.h   |  4 
 arch/mn10300/Kconfig|  1 +
 arch/nios2/include/asm/processor.h  |  5 -
 arch/openrisc/include/asm/processor.h   |  9 -
 arch/parisc/kernel/process.c|  7 ---
 arch/powerpc/kernel/process.c   |  4 
 arch/s390/Kconfig   |  1 +
 arch/score/kernel/process.c |  2 --
 arch/sh/Kconfig |  1 +
 arch/sh/kernel/process_32.c |  7 ---
 arch/sparc/Kconfig  |  1 +
 arch/tile/Kconfig   |  1 +
 arch/um/kernel/process.c|  4 
 arch/unicore32/kernel/process.c |  7 ---
 arch/x86/Kconfig|  1 +
 arch/xtensa/Kconfig |  1 +
 include/linux/sched.h   |  7 +++
 36 files changed, 24 insertions(+), 140 deletions(-)

diff --git a/arch/Kconfig b/arch/Kconfig
index 81869a5e7e17..0f298f9123dc 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -517,6 +517,11 @@ config HAVE_ARCH_MMAP_RND_BITS
  - ARCH_MMAP_RND_BITS_MIN
  - ARCH_MMAP_RND_BITS_MAX
 
+config HAVE_EXIT_THREAD
+   bool
+   help
+ An architecture implements exit_thread.
+
 config ARCH_MMAP_RND_BITS_MIN
int
 
diff --git a/arch/alpha/kernel/process.c b/arch/alpha/kernel/process.c
index 84d13263ce46..b483156698d5 100644
--- a/arch/alpha/kernel/process.c
+++ b/arch/alpha/kernel/process.c
@@ -210,14 +210,6 @@ start_thread(struct pt_regs * regs, unsigned long pc, 
unsigned long sp)
 }
 EXPORT_SYMBOL(start_thread);
 
-/*
- * Free current thread data structures etc..
- */
-void
-exit_thread(void)
-{
-}
-
 void
 flush_thread(void)
 {
diff --git a/arch/arc/kernel/process.c b/arch/arc/kernel/process.c
index a3f750e76b68..b5db9e7fd649 100644
--- a/arch/arc/kernel/process.c
+++ b/arch/arc/kernel/process.c
@@ -183,13 +183,6 @@ void flush_thread(void)
 {
 }
 
-/*
- * Free any architecture-

Re: [PATCH 2/3 v2] ASoC: dwc: Add I2S HDMI audio support

2016-03-31 Thread Mark Brown
On Thu, Mar 31, 2016 at 10:37:20AM +0100, Jose Abreu wrote:
> On 29-03-2016 19:22, Mark Brown wrote:

> > If you want to add a new platform driver you need to add a new platform
> > driver, not shove the code into an existing driver for a seperate IP.

> I can separate the platform driver into a new file but they will have to be
> compiled into the same module as the new additions to the i2s driver depend on
> functions of the platform driver (see i2s_irq_handler()). Or should I divide

No, that's not at all acceptable.  The Designware IP is not specific to
your system, you can't make it depend on your platform driver.  The
kernel needs to work on other people's systems too.  You need to work
through and/or extend the abstractions the framework provides to
separate the drivers for different IPs.

> this into two modules and add a Kconfig option to the platform driver? Besides
> this I first wanted the driver to be compiled into the same module so that it 
> is
> compatible with kernel 3.18 where simple audio card requires that platform
> driver == cpu driver.

That's not OK upstream, we're working on the current kernel not on
random old kernels.  We don't carry compatibility code to enable current
kernel code to be run on years old kernels.


signature.asc
Description: PGP signature
___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

[PATCH v3] clk/axs10x: Add I2S PLL clock driver

2016-03-31 Thread Jose Abreu
The ARC SDP I2S clock can be programmed using a
specific PLL.

This patch has the goal of adding a clock driver
that programs this PLL.

At this moment the rate values are hardcoded in
a table but in the future it would be ideal to
use a function which determines the PLL values
given the desired rate.

Signed-off-by: Jose Abreu 
---

Changes v2 -> v3:
* Implemented recalc_rate

Changes v1 -> v2:
* Renamed folder to axs10x (as suggested by Alexey Brodkin)
* Added more supported rates

 arch/arc/boot/dts/axs10x_mb.dtsi   |   5 ++
 drivers/clk/Makefile   |   1 +
 drivers/clk/axs10x/Makefile|   1 +
 drivers/clk/axs10x/i2s_pll_clock.c | 163 +
 4 files changed, 170 insertions(+)
 create mode 100644 drivers/clk/axs10x/Makefile
 create mode 100644 drivers/clk/axs10x/i2s_pll_clock.c

diff --git a/arch/arc/boot/dts/axs10x_mb.dtsi b/arch/arc/boot/dts/axs10x_mb.dtsi
index ab5d570..9c68226 100644
--- a/arch/arc/boot/dts/axs10x_mb.dtsi
+++ b/arch/arc/boot/dts/axs10x_mb.dtsi
@@ -23,6 +23,11 @@
#clock-cells = <0>;
};
 
+   i2sclk: i2sclk {
+   compatible = "snps,i2s-pll-clock";
+   #clock-cells = <0>;
+   };
+
apbclk: apbclk {
compatible = "fixed-clock";
clock-frequency = <5000>;
diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
index 46869d6..2ca62dc6 100644
--- a/drivers/clk/Makefile
+++ b/drivers/clk/Makefile
@@ -84,3 +84,4 @@ obj-$(CONFIG_X86) += x86/
 obj-$(CONFIG_ARCH_ZX)  += zte/
 obj-$(CONFIG_ARCH_ZYNQ)+= zynq/
 obj-$(CONFIG_H8300)+= h8300/
+obj-$(CONFIG_ARC_PLAT_AXS10X)  += axs10x/
diff --git a/drivers/clk/axs10x/Makefile b/drivers/clk/axs10x/Makefile
new file mode 100644
index 000..01996b8
--- /dev/null
+++ b/drivers/clk/axs10x/Makefile
@@ -0,0 +1 @@
+obj-y += i2s_pll_clock.o
diff --git a/drivers/clk/axs10x/i2s_pll_clock.c 
b/drivers/clk/axs10x/i2s_pll_clock.c
new file mode 100644
index 000..f050e70
--- /dev/null
+++ b/drivers/clk/axs10x/i2s_pll_clock.c
@@ -0,0 +1,163 @@
+/*
+ * Synopsys AXS10X SDP I2S PLL clock driver
+ *
+ * Copyright (C) 2016 Synopsys
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2. This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* FPGA Version Info */
+#define FPGA_VER_INFO  0xE0011230
+#define FPGA_VER_27M   0x000FBED9
+
+/* PLL registers addresses */
+#define PLL_IDIV_ADDR  0xE00100A0
+#define PLL_FBDIV_ADDR 0xE00100A4
+#define PLL_ODIV0_ADDR 0xE00100A8
+#define PLL_ODIV1_ADDR 0xE00100AC
+
+struct i2s_pll_cfg {
+   unsigned int rate;
+   unsigned int idiv;
+   unsigned int fbdiv;
+   unsigned int odiv0;
+   unsigned int odiv1;
+};
+
+static struct i2s_pll_cfg i2s_pll_cfg_27m[] = {
+   /* 27 Mhz */
+   { 1024000, 0x104, 0x451, 0x10E38, 0x2000 },
+   { 1411200, 0x104, 0x596, 0x10D35, 0x2000 },
+   { 1536000, 0x208, 0xA28, 0x10B2C, 0x2000 },
+   { 2048000, 0x82, 0x451, 0x10E38, 0x2000 },
+   { 2822400, 0x82, 0x596, 0x10D35, 0x2000 },
+   { 3072000, 0x104, 0xA28, 0x10B2C, 0x2000 },
+   { 2116800, 0x82, 0x3CF, 0x10C30, 0x2000 },
+   { 2304000, 0x104, 0x79E, 0x10B2C, 0x2000 },
+   { 0, 0, 0, 0, 0 },
+};
+
+static struct i2s_pll_cfg i2s_pll_cfg_28m[] = {
+   /* 28.224 Mhz */
+   { 1024000, 0x82, 0x105, 0x107DF, 0x2000 },
+   { 1411200, 0x28A, 0x1, 0x10001, 0x2000 },
+   { 1536000, 0xA28, 0x187, 0x10042, 0x2000 },
+   { 2048000, 0x41, 0x105, 0x107DF, 0x2000 },
+   { 2822400, 0x145, 0x1, 0x10001, 0x2000 },
+   { 3072000, 0x514, 0x187, 0x10042, 0x2000 },
+   { 2116800, 0x514, 0x42, 0x10001, 0x2000 },
+   { 2304000, 0x619, 0x82, 0x10001, 0x2000 },
+   { 0, 0, 0, 0, 0 },
+};
+
+struct i2s_pll_clk {
+   struct clk_hw hw;
+   unsigned long ref_clk;
+   struct i2s_pll_cfg *pll_cfg;
+};
+
+static inline struct i2s_pll_clk *to_i2s_pll_clk(struct clk_hw *hw)
+{
+   return container_of(hw, struct i2s_pll_clk, hw);
+}
+
+static unsigned int i2s_pll_get_value(unsigned int val)
+{
+   return ((val & 0x3F) + ((val >> 6) & 0x3F));
+}
+
+static unsigned long i2s_pll_recalc_rate(struct clk_hw *hw,
+   unsigned long parent_rate)
+{
+   struct i2s_pll_clk *clk = to_i2s_pll_clk(hw);
+   unsigned int idiv, fbdiv, odiv;
+
+   idiv = i2s_pll_get_value(readl((void *)PLL_IDIV_ADDR));
+   fbdiv = i2s_pll_get_value(readl((void *)PLL_FBDIV_ADDR));
+   odiv = i2s_pll_get_value(readl((void *)PLL_ODIV0_ADDR));
+
+   return (((clk->ref_clk / idiv ) * fbdiv) / odiv);
+}
+
+static long i2s_pll_round_rate(struct clk_hw *hw, un