Re: [v3 PATCH 1/6] drivers: reset: TI: SoC reset controller support.

2014-07-22 Thread Suman Anna
Hi Dan,

On 07/17/2014 11:45 AM, Murphy, Dan wrote:
 The TI SoC reset controller support utilizes the
 reset controller framework to give device drivers or
 function drivers a common set of APIs to call to reset
 a module.
 
 The reset-ti is a common interface to the reset framework.
  The register data is retrieved during initialization
  of the reset driver through the reset-ti-data
 file. The array of data is associated with the compatible from the
 respective DT entry.

Outdated commit description, this is no longer correct.

 
 Once the data is available then this is derefenced within the common
 interface.
 
 The device driver has the ability to assert, deassert or perform a
 complete reset.
 
 This code was derived from previous work by Rajendra Nayak and Afzal Mohammed.
 The code was changed to adopt to the reset core and abstract away the SoC 
 information.
 
 Signed-off-by: Dan Murphy dmur...@ti.com
 ---
 
 v3 - Resolved comments from v2.  To many to call out here - 
 https://patchwork.kernel.org/patch/4116941/

Please add a cover letter for the series next time and make sure you cc
the reset driver maintainer.

 
  drivers/reset/Kconfig|9 ++
  drivers/reset/Makefile   |1 +
  drivers/reset/reset-ti.c |  373 
 ++
  3 files changed, 383 insertions(+)
  create mode 100644 drivers/reset/reset-ti.c
 
 diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig
 index 0615f50..31a5a79 100644
 --- a/drivers/reset/Kconfig
 +++ b/drivers/reset/Kconfig
 @@ -12,4 +12,13 @@ menuconfig RESET_CONTROLLER
  
 If unsure, say no.
  
 +config RESET_TI
 + depends on RESET_CONTROLLER  ARCH_OMAP || COMPILE_TEST
 + bool TI reset controller
 + help
 +   Reset controller support for TI SoC's
 +
 +   Reset controller found in TI's AM series of SoC's like
 +   AM335x and AM43x and OMAP SoC's like OMAP5 and DRA7
 +
  source drivers/reset/sti/Kconfig
 diff --git a/drivers/reset/Makefile b/drivers/reset/Makefile
 index 60fed3d..a5986b9 100644
 --- a/drivers/reset/Makefile
 +++ b/drivers/reset/Makefile
 @@ -1,4 +1,5 @@
  obj-$(CONFIG_RESET_CONTROLLER) += core.o
  obj-$(CONFIG_ARCH_SOCFPGA) += reset-socfpga.o
  obj-$(CONFIG_ARCH_SUNXI) += reset-sunxi.o
 +obj-$(CONFIG_RESET_TI) += reset-ti.o
  obj-$(CONFIG_ARCH_STI) += sti/
 diff --git a/drivers/reset/reset-ti.c b/drivers/reset/reset-ti.c
 new file mode 100644
 index 000..e9d4039
 --- /dev/null
 +++ b/drivers/reset/reset-ti.c
 @@ -0,0 +1,373 @@
 +/*
 + * reset-ti.c - PRCM reset driver for TI SoC's
 + *
 + * Copyright (C) 2014 Texas Instruments Incorporated -  http://www.ti.com
 + *
 + * Author: Dan Murphy dmur...@ti.com
 + *
 + * This program is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License version 2 as
 + * published by the Free Software Foundation.
 + */
 +
 +#include linux/delay.h
 +#include linux/device.h
 +#include linux/err.h
 +#include linux/io.h
 +#include linux/kernel.h
 +#include linux/module.h
 +#include linux/of_address.h

This header is no longer needed, now that you are not using of_iomap.

 +#include linux/of_device.h
 +#include linux/platform_device.h
 +#include linux/reset.h
 +#include linux/reset-controller.h
 +#include linux/slab.h
 +#include linux/spinlock.h
 +
 +#define DRIVER_NAME prcm_reset_ti
 +#define MAX_RESET_SIGNALS 255

This sounds like a lot, I think you should reduce this to not waste
memory. Start with a small number, and add a trace for increasing this
if you run out of the current slots.

 +
 +/**
 + * struct ti_reset_reg_data - Structure of the reset register information
 + *   for a particular SoC.
 + * @rstctrl_offs: This is the reset control offset value from
 + *   from the parent reset node.
 + * @rstst_offs: This is the reset status offset value from
 + *   from the parent reset node.
 + * @rstctrl_bit: This is the reset control bit for the module.
 + * @rstst_bit: This is the reset status bit for the module.
 + *
 + * Longer description of this structure.
 + */
 +struct ti_reset_reg_data {
 + phandle handle;
 + u32 rstctrl_offs;
 + u32 rstst_offs;
 + u32 rstctrl_bit;
 + u32 rstst_bit;
 +};
 +
 +/**
 + * struct ti_reset_data - Structure that contains the reset register data
 + *   as well as the total number of resets for a particular SoC.
 + * @ti_data: Pointer to this structure to be dereferenced
 + * @reg_data:Pointer to the register data structure.
 + * @rcdev:   Reset controller device instance
 + * @dev: Pointer to the devive structure
 + * @ti_reg_data: Array of register data.  Only reset signal with valid
 + *   phandles will be stored in this array.
 + * @reg_base:Parent register base address
 + * @lock:Spinlock for accessing the registers
 + * @nr_resets:   Total number of resets for the SoC in the reset array.
 + *
 + * This structure 

Re: [v3 PATCH 1/6] drivers: reset: TI: SoC reset controller support.

2014-07-18 Thread Lothar Waßmann
Hi,

Dan Murphy wrote:
 The TI SoC reset controller support utilizes the
 reset controller framework to give device drivers or
 function drivers a common set of APIs to call to reset
 a module.
 
 The reset-ti is a common interface to the reset framework.
  The register data is retrieved during initialization
  of the reset driver through the reset-ti-data
 file.  The array of data is associated with the compatible from the
 respective DT entry.
 
 Once the data is available then this is derefenced within the common
 interface.
 
 The device driver has the ability to assert, deassert or perform a
 complete reset.
 
 This code was derived from previous work by Rajendra Nayak and Afzal Mohammed.
 The code was changed to adopt to the reset core and abstract away the SoC 
 information.
 
 Signed-off-by: Dan Murphy dmur...@ti.com
 ---
 
 v3 - Resolved comments from v2.  To many to call out here - 
 https://patchwork.kernel.org/patch/4116941/
 
  drivers/reset/Kconfig|9 ++
  drivers/reset/Makefile   |1 +
  drivers/reset/reset-ti.c |  373 
 ++
  3 files changed, 383 insertions(+)
  create mode 100644 drivers/reset/reset-ti.c
 
 diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig
 index 0615f50..31a5a79 100644
 --- a/drivers/reset/Kconfig
 +++ b/drivers/reset/Kconfig
 @@ -12,4 +12,13 @@ menuconfig RESET_CONTROLLER
  
 If unsure, say no.
  
 +config RESET_TI
 + depends on RESET_CONTROLLER  ARCH_OMAP || COMPILE_TEST
 + bool TI reset controller
 + help
 +   Reset controller support for TI SoC's
 +
 +   Reset controller found in TI's AM series of SoC's like
 +   AM335x and AM43x and OMAP SoC's like OMAP5 and DRA7
 +
  source drivers/reset/sti/Kconfig
 diff --git a/drivers/reset/Makefile b/drivers/reset/Makefile
 index 60fed3d..a5986b9 100644
 --- a/drivers/reset/Makefile
 +++ b/drivers/reset/Makefile
 @@ -1,4 +1,5 @@
  obj-$(CONFIG_RESET_CONTROLLER) += core.o
  obj-$(CONFIG_ARCH_SOCFPGA) += reset-socfpga.o
  obj-$(CONFIG_ARCH_SUNXI) += reset-sunxi.o
 +obj-$(CONFIG_RESET_TI) += reset-ti.o
  obj-$(CONFIG_ARCH_STI) += sti/
 diff --git a/drivers/reset/reset-ti.c b/drivers/reset/reset-ti.c
 new file mode 100644
 index 000..e9d4039
 --- /dev/null
 +++ b/drivers/reset/reset-ti.c
 @@ -0,0 +1,373 @@
 +/*
 + * reset-ti.c - PRCM reset driver for TI SoC's
 + *
 + * Copyright (C) 2014 Texas Instruments Incorporated -  http://www.ti.com
 + *
 + * Author: Dan Murphy dmur...@ti.com
 + *
 + * This program is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License version 2 as
 + * published by the Free Software Foundation.
 + */
 +
 +#include linux/delay.h
 +#include linux/device.h
 +#include linux/err.h
 +#include linux/io.h
 +#include linux/kernel.h
 +#include linux/module.h
 +#include linux/of_address.h
 +#include linux/of_device.h
 +#include linux/platform_device.h
 +#include linux/reset.h
 +#include linux/reset-controller.h
 +#include linux/slab.h
 +#include linux/spinlock.h
 +
 +#define DRIVER_NAME prcm_reset_ti
 +#define MAX_RESET_SIGNALS 255
 +
 +/**
 + * struct ti_reset_reg_data - Structure of the reset register information
 + *   for a particular SoC.
 + * @rstctrl_offs: This is the reset control offset value from
 + *   from the parent reset node.
 + * @rstst_offs: This is the reset status offset value from
 + *   from the parent reset node.
 + * @rstctrl_bit: This is the reset control bit for the module.
 + * @rstst_bit: This is the reset status bit for the module.
 + *
 + * Longer description of this structure.
 + */
 +struct ti_reset_reg_data {
 + phandle handle;
 + u32 rstctrl_offs;
 + u32 rstst_offs;
 + u32 rstctrl_bit;
 + u32 rstst_bit;
 +};
 +
 +/**
 + * struct ti_reset_data - Structure that contains the reset register data
 + *   as well as the total number of resets for a particular SoC.
 + * @ti_data: Pointer to this structure to be dereferenced
 + * @reg_data:Pointer to the register data structure.
 + * @rcdev:   Reset controller device instance
 + * @dev: Pointer to the devive structure
 + * @ti_reg_data: Array of register data.  Only reset signal with valid
 + *   phandles will be stored in this array.
 + * @reg_base:Parent register base address
 + * @lock:Spinlock for accessing the registers
 + * @nr_resets:   Total number of resets for the SoC in the reset array.
 + *
 + * This structure contains a pointer to the register data and the modules
 + * register base.  The number of resets and reset controller device data is
 + * stored within this structure.
 + *
 + */
 +struct ti_reset_data {
 + struct ti_reset_data *ti_data;
 + struct ti_reset_reg_data *reg_data;
 + struct reset_controller_dev rcdev;
 + struct device *dev;
 + struct ti_reset_reg_data ti_reg_data[MAX_RESET_SIGNALS];
 + void __iomem 

[v3 PATCH 1/6] drivers: reset: TI: SoC reset controller support.

2014-07-17 Thread Dan Murphy
The TI SoC reset controller support utilizes the
reset controller framework to give device drivers or
function drivers a common set of APIs to call to reset
a module.

The reset-ti is a common interface to the reset framework.
 The register data is retrieved during initialization
 of the reset driver through the reset-ti-data
file.  The array of data is associated with the compatible from the
respective DT entry.

Once the data is available then this is derefenced within the common
interface.

The device driver has the ability to assert, deassert or perform a
complete reset.

This code was derived from previous work by Rajendra Nayak and Afzal Mohammed.
The code was changed to adopt to the reset core and abstract away the SoC 
information.

Signed-off-by: Dan Murphy dmur...@ti.com
---

v3 - Resolved comments from v2.  To many to call out here - 
https://patchwork.kernel.org/patch/4116941/

 drivers/reset/Kconfig|9 ++
 drivers/reset/Makefile   |1 +
 drivers/reset/reset-ti.c |  373 ++
 3 files changed, 383 insertions(+)
 create mode 100644 drivers/reset/reset-ti.c

diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig
index 0615f50..31a5a79 100644
--- a/drivers/reset/Kconfig
+++ b/drivers/reset/Kconfig
@@ -12,4 +12,13 @@ menuconfig RESET_CONTROLLER
 
  If unsure, say no.
 
+config RESET_TI
+   depends on RESET_CONTROLLER  ARCH_OMAP || COMPILE_TEST
+   bool TI reset controller
+   help
+ Reset controller support for TI SoC's
+
+ Reset controller found in TI's AM series of SoC's like
+ AM335x and AM43x and OMAP SoC's like OMAP5 and DRA7
+
 source drivers/reset/sti/Kconfig
diff --git a/drivers/reset/Makefile b/drivers/reset/Makefile
index 60fed3d..a5986b9 100644
--- a/drivers/reset/Makefile
+++ b/drivers/reset/Makefile
@@ -1,4 +1,5 @@
 obj-$(CONFIG_RESET_CONTROLLER) += core.o
 obj-$(CONFIG_ARCH_SOCFPGA) += reset-socfpga.o
 obj-$(CONFIG_ARCH_SUNXI) += reset-sunxi.o
+obj-$(CONFIG_RESET_TI) += reset-ti.o
 obj-$(CONFIG_ARCH_STI) += sti/
diff --git a/drivers/reset/reset-ti.c b/drivers/reset/reset-ti.c
new file mode 100644
index 000..e9d4039
--- /dev/null
+++ b/drivers/reset/reset-ti.c
@@ -0,0 +1,373 @@
+/*
+ * reset-ti.c - PRCM reset driver for TI SoC's
+ *
+ * Copyright (C) 2014 Texas Instruments Incorporated -  http://www.ti.com
+ *
+ * Author: Dan Murphy dmur...@ti.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include linux/delay.h
+#include linux/device.h
+#include linux/err.h
+#include linux/io.h
+#include linux/kernel.h
+#include linux/module.h
+#include linux/of_address.h
+#include linux/of_device.h
+#include linux/platform_device.h
+#include linux/reset.h
+#include linux/reset-controller.h
+#include linux/slab.h
+#include linux/spinlock.h
+
+#define DRIVER_NAME prcm_reset_ti
+#define MAX_RESET_SIGNALS 255
+
+/**
+ * struct ti_reset_reg_data - Structure of the reset register information
+ * for a particular SoC.
+ * @rstctrl_offs: This is the reset control offset value from
+ * from the parent reset node.
+ * @rstst_offs: This is the reset status offset value from
+ * from the parent reset node.
+ * @rstctrl_bit: This is the reset control bit for the module.
+ * @rstst_bit: This is the reset status bit for the module.
+ *
+ * Longer description of this structure.
+ */
+struct ti_reset_reg_data {
+   phandle handle;
+   u32 rstctrl_offs;
+   u32 rstst_offs;
+   u32 rstctrl_bit;
+   u32 rstst_bit;
+};
+
+/**
+ * struct ti_reset_data - Structure that contains the reset register data
+ * as well as the total number of resets for a particular SoC.
+ * @ti_data:   Pointer to this structure to be dereferenced
+ * @reg_data:  Pointer to the register data structure.
+ * @rcdev: Reset controller device instance
+ * @dev:   Pointer to the devive structure
+ * @ti_reg_data: Array of register data.  Only reset signal with valid
+ * phandles will be stored in this array.
+ * @reg_base:  Parent register base address
+ * @lock:  Spinlock for accessing the registers
+ * @nr_resets: Total number of resets for the SoC in the reset array.
+ *
+ * This structure contains a pointer to the register data and the modules
+ * register base.  The number of resets and reset controller device data is
+ * stored within this structure.
+ *
+ */
+struct ti_reset_data {
+   struct ti_reset_data *ti_data;
+   struct ti_reset_reg_data *reg_data;
+   struct reset_controller_dev rcdev;
+   struct device *dev;
+   struct ti_reset_reg_data ti_reg_data[MAX_RESET_SIGNALS];
+   void __iomem *reg_base;
+   spinlock_t lock;
+   int nr_resets;
+};
+
+static int ti_reset_wait_on_reset(struct reset_controller_dev *rcdev,