mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 00/20] AT91, at91sam9x5ek updates (part I/III)
@ 2017-03-08 22:08 Andrey Smirnov
  2017-03-08 22:08 ` [PATCH 01/20] at91: Fix bug/typo in debug_ll.h Andrey Smirnov
                   ` (20 more replies)
  0 siblings, 21 replies; 23+ messages in thread
From: Andrey Smirnov @ 2017-03-08 22:08 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Hi everone,

As discussed in original thread [1], here is a first batch of AT91
related patches. The patches gathered in this set are bugfixes, port
of functionality form Linux or code refactoring.

Feedback from Sascha and Sam has been incorporated, but other than
that the code should be as it was in [1].

Any feedback is appreciated.

Thank you,
Andrey Smirnov

[1] http://lists.infradead.org/pipermail/barebox/2017-March/029337.html


Andrey Smirnov (20):
  at91: Fix bug/typo in debug_ll.h
  regmap: Implement syscon_node_to_regmap()
  pinctrl: at91: Fix a bug in at91_pinctrl_set_conf()
  pinctrl: at91: Fix a bug in at91_pinctrl_set_state()
  pinctrl: at91: Implement .get_direction hook
  clk: Port two helper functions from Linux
  clk: Make COMMON_CLK_OF_PROVIDER depend on OFTREE
  clk: No-op CLK_OF_DECLARE if not enabled
  of: base: Use scoring in DT device matching
  serial: atmel: Check result of clk_get()
  usb: ohci-at91: Check result of clk_get()
  usb: ohci-at91: Convert global variables to private data
  usb: ohci-at91: Check result of clk_enable()
  usb: ehci-atmel: Check result of clk_enable()
  usb: echi-atmel: Convert global variables to private data
  usb: ehci-atmel: Zero ehci_data before using it
  usb: echi-atmel: Check result of ehci_register()
  spi: atmel_spi: Configure CS GPIO as output
  spi: atmel_spi: Use VERSION register instead of CPU type
  clocksource: at91: Move to 'drivers/clocksource'

 arch/arm/mach-at91/Kconfig                         |  7 +-
 arch/arm/mach-at91/Makefile                        |  1 -
 arch/arm/mach-at91/include/mach/debug_ll.h         |  2 +-
 drivers/clk/Kconfig                                |  1 +
 drivers/clk/clk-fixed-factor.c                     |  2 -
 drivers/clk/clk-fixed.c                            |  3 +-
 drivers/clk/clk.c                                  | 41 +++++++++++-
 drivers/clk/clkdev.c                               |  2 +-
 drivers/clocksource/Kconfig                        |  4 ++
 drivers/clocksource/Makefile                       |  1 +
 .../clocksource/timer-atmel-pit.c                  |  0
 drivers/mfd/syscon.c                               | 54 ++++++++++++++-
 drivers/of/base.c                                  | 37 ++++++-----
 drivers/pinctrl/pinctrl-at91.c                     | 22 ++++++-
 drivers/serial/atmel.c                             |  5 ++
 drivers/spi/atmel_spi.c                            | 41 ++++++++++--
 drivers/spi/atmel_spi.h                            |  1 +
 drivers/usb/host/ehci-atmel.c                      | 57 +++++++++++-----
 drivers/usb/host/ohci-at91.c                       | 76 +++++++++++++++++-----
 include/linux/clk.h                                |  9 ++-
 include/mfd/syscon.h                               |  8 +++
 21 files changed, 299 insertions(+), 75 deletions(-)
 rename arch/arm/mach-at91/at91sam926x_time.c => drivers/clocksource/timer-atmel-pit.c (100%)

-- 
2.9.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH 01/20] at91: Fix bug/typo in debug_ll.h
  2017-03-08 22:08 [PATCH 00/20] AT91, at91sam9x5ek updates (part I/III) Andrey Smirnov
@ 2017-03-08 22:08 ` Andrey Smirnov
  2017-03-08 22:08 ` [PATCH 02/20] regmap: Implement syscon_node_to_regmap() Andrey Smirnov
                   ` (19 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: Andrey Smirnov @ 2017-03-08 22:08 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Correct "COFNIG" to "CONFIG".

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 arch/arm/mach-at91/include/mach/debug_ll.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/mach-at91/include/mach/debug_ll.h b/arch/arm/mach-at91/include/mach/debug_ll.h
index 1a85ae4..42728a4 100644
--- a/arch/arm/mach-at91/include/mach/debug_ll.h
+++ b/arch/arm/mach-at91/include/mach/debug_ll.h
@@ -11,7 +11,7 @@
 #include <asm/io.h>
 #include <mach/hardware.h>
 
-#ifdef COFNIG_HAVE_AT91_DBGU0
+#ifdef CONFIG_HAVE_AT91_DBGU0
 #define UART_BASE	AT91_BASE_DBGU0
 #else
 #define UART_BASE	AT91_BASE_DBGU1
-- 
2.9.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH 02/20] regmap: Implement syscon_node_to_regmap()
  2017-03-08 22:08 [PATCH 00/20] AT91, at91sam9x5ek updates (part I/III) Andrey Smirnov
  2017-03-08 22:08 ` [PATCH 01/20] at91: Fix bug/typo in debug_ll.h Andrey Smirnov
@ 2017-03-08 22:08 ` Andrey Smirnov
  2017-03-08 22:08 ` [PATCH 03/20] pinctrl: at91: Fix a bug in at91_pinctrl_set_conf() Andrey Smirnov
                   ` (18 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: Andrey Smirnov @ 2017-03-08 22:08 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Implement syscon_node_to_regmap() to simplify porting kernel code.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/mfd/syscon.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 include/mfd/syscon.h |  8 ++++++++
 2 files changed, 61 insertions(+), 1 deletion(-)

diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
index 6ef30ce..957d9a7 100644
--- a/drivers/mfd/syscon.c
+++ b/drivers/mfd/syscon.c
@@ -28,6 +28,34 @@ struct syscon {
 	struct device_node *np;
 	void __iomem *base;
 	struct list_head list;
+	struct regmap *regmap;
+};
+
+static int syscon_reg_write(void *context, unsigned int reg,
+			    unsigned int val)
+{
+	struct syscon *syscon = context;
+	writel(val, syscon->base + reg);
+	return 0;
+}
+
+static int syscon_reg_read(void *context, unsigned int reg,
+			   unsigned int *val)
+{
+	struct syscon *syscon = context;
+	*val = readl(syscon->base + reg);
+	return 0;
+}
+
+static const struct regmap_bus syscon_regmap_bus = {
+	.reg_write = syscon_reg_write,
+	.reg_read  = syscon_reg_read,
+};
+
+static const struct regmap_config syscon_regmap_config = {
+	.reg_bits = 32,
+	.val_bits = 32,
+	.reg_stride = 4,
 };
 
 static struct syscon *of_syscon_register(struct device_node *np)
@@ -51,6 +79,10 @@ static struct syscon *of_syscon_register(struct device_node *np)
 
 	list_add_tail(&syscon->list, &syscon_list);
 
+	syscon->regmap = regmap_init(NULL,
+				     &syscon_regmap_bus,
+				     syscon,
+				     &syscon_regmap_config);
 	return syscon;
 
 err_map:
@@ -58,7 +90,7 @@ err_map:
 	return ERR_PTR(ret);
 }
 
-static void __iomem *syscon_node_to_base(struct device_node *np)
+static struct syscon *node_to_syscon(struct device_node *np)
 {
 	struct syscon *entry, *syscon = NULL;
 
@@ -74,6 +106,16 @@ static void __iomem *syscon_node_to_base(struct device_node *np)
 	if (IS_ERR(syscon))
 		return ERR_CAST(syscon);
 
+	return syscon;
+}
+
+static void __iomem *syscon_node_to_base(struct device_node *np)
+{
+	struct syscon *syscon = node_to_syscon(np);
+
+	if (IS_ERR(syscon))
+		return ERR_CAST(syscon);
+
 	return syscon->base;
 }
 
@@ -108,6 +150,16 @@ void __iomem *syscon_base_lookup_by_phandle(struct device_node *np,
 	return syscon_node_to_base(syscon_np);
 }
 
+struct regmap *syscon_node_to_regmap(struct device_node *np)
+{
+	struct syscon *syscon = node_to_syscon(np);
+
+	if (IS_ERR(syscon))
+		return ERR_CAST(syscon);
+
+	return syscon->regmap;
+}
+
 static int syscon_probe(struct device_d *dev)
 {
 	struct syscon *syscon;
diff --git a/include/mfd/syscon.h b/include/mfd/syscon.h
index 651d4c2..63b893e 100644
--- a/include/mfd/syscon.h
+++ b/include/mfd/syscon.h
@@ -14,10 +14,13 @@
 #ifndef __MFD_SYSCON_H__
 #define __MFD_SYSCON_H__
 
+#include <regmap.h>
+
 #ifdef CONFIG_MFD_SYSCON
 void __iomem *syscon_base_lookup_by_pdevname(const char *s);
 void __iomem *syscon_base_lookup_by_phandle
 	(struct device_node *np, const char *property);
+struct regmap *syscon_node_to_regmap(struct device_node *np);
 #else
 static inline void __iomem *syscon_base_lookup_by_pdevname(const char *s)
 {
@@ -29,6 +32,11 @@ static inline void __iomem *syscon_base_lookup_by_phandle
 {
 	return ERR_PTR(-ENOSYS);
 }
+
+static inline struct regmap *syscon_node_to_regmap(struct device_node *np)
+{
+	return ERR_PTR(-ENOSYS);
+}
 #endif
 
 #endif
-- 
2.9.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH 03/20] pinctrl: at91: Fix a bug in at91_pinctrl_set_conf()
  2017-03-08 22:08 [PATCH 00/20] AT91, at91sam9x5ek updates (part I/III) Andrey Smirnov
  2017-03-08 22:08 ` [PATCH 01/20] at91: Fix bug/typo in debug_ll.h Andrey Smirnov
  2017-03-08 22:08 ` [PATCH 02/20] regmap: Implement syscon_node_to_regmap() Andrey Smirnov
@ 2017-03-08 22:08 ` Andrey Smirnov
  2017-03-08 22:08 ` [PATCH 04/20] pinctrl: at91: Fix a bug in at91_pinctrl_set_state() Andrey Smirnov
                   ` (17 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: Andrey Smirnov @ 2017-03-08 22:08 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Pin_to_controller returns struct at91_gpio_chip, whereas at91_mux_*
functions expect void __iomem * pointing to controller register
window. Fix the code to do appropriate conversion between the two.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/pinctrl/pinctrl-at91.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c
index ebbc6f6..e24c9be 100644
--- a/drivers/pinctrl/pinctrl-at91.c
+++ b/drivers/pinctrl/pinctrl-at91.c
@@ -414,8 +414,10 @@ static int at91_pinctrl_set_conf(struct at91_pinctrl *info, unsigned int pin_num
 {
 	unsigned int mask;
 	void __iomem *pio;
+	struct at91_gpio_chip *at91_gpio;
 
-	pio = pin_to_controller(pin_num);
+	at91_gpio = pin_to_controller(pin_num);
+	pio  = at91_gpio->regbase;
 	mask = pin_to_mask(pin_num);
 
 	if (conf & PULL_UP && conf & PULL_DOWN)
-- 
2.9.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH 04/20] pinctrl: at91: Fix a bug in at91_pinctrl_set_state()
  2017-03-08 22:08 [PATCH 00/20] AT91, at91sam9x5ek updates (part I/III) Andrey Smirnov
                   ` (2 preceding siblings ...)
  2017-03-08 22:08 ` [PATCH 03/20] pinctrl: at91: Fix a bug in at91_pinctrl_set_conf() Andrey Smirnov
@ 2017-03-08 22:08 ` Andrey Smirnov
  2017-03-08 22:08 ` [PATCH 05/20] pinctrl: at91: Implement .get_direction hook Andrey Smirnov
                   ` (16 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: Andrey Smirnov @ 2017-03-08 22:08 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Pin number, as specified in OF pinumx entries, is relative to each bank
start, whereas both at91_mux_pin() and at91_pinctrl_set_conf() asssume
absolute pin numbering, so we need to take into account each bank's pin
base and convert pin number appropriately. Failing to do so results in
any pinmux configuration being applied to pins in bank A.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/pinctrl/pinctrl-at91.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c
index e24c9be..34fb0ae 100644
--- a/drivers/pinctrl/pinctrl-at91.c
+++ b/drivers/pinctrl/pinctrl-at91.c
@@ -462,6 +462,8 @@ static int at91_pinctrl_set_state(struct pinctrl_device *pdev, struct device_nod
 		mux = be32_to_cpu(*list++);
 		conf = be32_to_cpu(*list++);
 
+		pin_num += bank_num * MAX_NB_GPIO_PER_BANK;
+
 		ret = at91_mux_pin(pin_num, mux, conf & PULL_UP);
 		if (ret) {
 			dev_err(pdev->dev, "failed to mux pin %d\n", pin_num);
-- 
2.9.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH 05/20] pinctrl: at91: Implement .get_direction hook
  2017-03-08 22:08 [PATCH 00/20] AT91, at91sam9x5ek updates (part I/III) Andrey Smirnov
                   ` (3 preceding siblings ...)
  2017-03-08 22:08 ` [PATCH 04/20] pinctrl: at91: Fix a bug in at91_pinctrl_set_state() Andrey Smirnov
@ 2017-03-08 22:08 ` Andrey Smirnov
  2017-03-08 22:08 ` [PATCH 06/20] clk: Port two helper functions from Linux Andrey Smirnov
                   ` (15 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: Andrey Smirnov @ 2017-03-08 22:08 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/pinctrl/pinctrl-at91.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c
index 34fb0ae..021c1e5 100644
--- a/drivers/pinctrl/pinctrl-at91.c
+++ b/drivers/pinctrl/pinctrl-at91.c
@@ -568,6 +568,21 @@ static int at91_gpio_direction_output(struct gpio_chip *chip, unsigned offset,
 	return 0;
 }
 
+static int at91_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
+{
+	struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip);
+	void __iomem *pio = at91_gpio->regbase;
+	unsigned mask = 1 << offset;
+	u32 osr;
+
+	if (mask & __raw_readl(pio + PIO_PSR)) {
+		osr = __raw_readl(pio + PIO_OSR);
+		return !(osr & mask);
+	} else {
+		return -EBUSY;
+	}
+}
+
 static int at91_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
 {
 	struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip);
@@ -603,6 +618,7 @@ static struct gpio_ops at91_gpio_ops = {
 	.free = at91_gpio_free,
 	.direction_input = at91_gpio_direction_input,
 	.direction_output = at91_gpio_direction_output,
+	.get_direction = at91_gpio_get_direction,
 	.get = at91_gpio_get,
 	.set = at91_gpio_set,
 };
-- 
2.9.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH 06/20] clk: Port two helper functions from Linux
  2017-03-08 22:08 [PATCH 00/20] AT91, at91sam9x5ek updates (part I/III) Andrey Smirnov
                   ` (4 preceding siblings ...)
  2017-03-08 22:08 ` [PATCH 05/20] pinctrl: at91: Implement .get_direction hook Andrey Smirnov
@ 2017-03-08 22:08 ` Andrey Smirnov
  2017-03-08 22:08 ` [PATCH 07/20] clk: Make COMMON_CLK_OF_PROVIDER depend on OFTREE Andrey Smirnov
                   ` (14 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: Andrey Smirnov @ 2017-03-08 22:08 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Port of_clk_get_parent_count() and of_clk_parent_fill() from Linux.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/clk/clk.c   | 39 +++++++++++++++++++++++++++++++++++++++
 include/linux/clk.h |  3 +++
 2 files changed, 42 insertions(+)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 93e000c..9189521 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -452,6 +452,24 @@ struct clk *of_clk_get_from_provider(struct of_phandle_args *clkspec)
 	return clk;
 }
 
+/**
+ * of_clk_get_parent_count() - Count the number of clocks a device node has
+ * @np: device node to count
+ *
+ * Returns: The number of clocks that are possible parents of this node
+ */
+unsigned int of_clk_get_parent_count(struct device_node *np)
+{
+	int count;
+
+	count = of_count_phandle_with_args(np, "clocks", "#clock-cells");
+	if (count < 0)
+		return 0;
+
+	return count;
+}
+EXPORT_SYMBOL_GPL(of_clk_get_parent_count);
+
 char *of_clk_get_parent_name(struct device_node *np, unsigned int index)
 {
 	struct of_phandle_args clkspec;
@@ -472,6 +490,27 @@ char *of_clk_get_parent_name(struct device_node *np, unsigned int index)
 }
 EXPORT_SYMBOL_GPL(of_clk_get_parent_name);
 
+/**
+ * of_clk_parent_fill() - Fill @parents with names of @np's parents and return
+ * number of parents
+ * @np: Device node pointer associated with clock provider
+ * @parents: pointer to char array that hold the parents' names
+ * @size: size of the @parents array
+ *
+ * Return: number of parents for the clock node.
+ */
+int of_clk_parent_fill(struct device_node *np, const char **parents,
+		       unsigned int size)
+{
+	unsigned int i = 0;
+
+	while (i < size && (parents[i] = of_clk_get_parent_name(np, i)) != NULL)
+		i++;
+
+	return i;
+}
+EXPORT_SYMBOL_GPL(of_clk_parent_fill);
+
 struct clock_provider {
 	of_clk_init_cb_t clk_init_cb;
 	struct device_node *np;
diff --git a/include/linux/clk.h b/include/linux/clk.h
index 7dd5238..f73b029 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -348,7 +348,10 @@ struct clk *of_clk_src_simple_get(struct of_phandle_args *clkspec, void *data);
 struct clk *of_clk_get(struct device_node *np, int index);
 struct clk *of_clk_get_by_name(struct device_node *np, const char *name);
 struct clk *of_clk_get_from_provider(struct of_phandle_args *clkspec);
+unsigned int of_clk_get_parent_count(struct device_node *np);
 char *of_clk_get_parent_name(struct device_node *np, unsigned int index);
+int of_clk_parent_fill(struct device_node *np, const char **parents,
+		       unsigned int size);
 int of_clk_init(struct device_node *root, const struct of_device_id *matches);
 #else
 static inline struct clk *of_clk_get(struct device_node *np, int index)
-- 
2.9.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH 07/20] clk: Make COMMON_CLK_OF_PROVIDER depend on OFTREE
  2017-03-08 22:08 [PATCH 00/20] AT91, at91sam9x5ek updates (part I/III) Andrey Smirnov
                   ` (5 preceding siblings ...)
  2017-03-08 22:08 ` [PATCH 06/20] clk: Port two helper functions from Linux Andrey Smirnov
@ 2017-03-08 22:08 ` Andrey Smirnov
  2017-03-08 22:08 ` [PATCH 08/20] clk: No-op CLK_OF_DECLARE if not enabled Andrey Smirnov
                   ` (13 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: Andrey Smirnov @ 2017-03-08 22:08 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Make COMMON_CLK_OF_PROVIDER depend on OFTREE, this way checking for:

	defined(CONFIG_OFTREE) && defined(CONFIG_COMMON_CLK_OF_PROVIDER)

can be simplified to just:

	defined(CONFIG_COMMON_CLK_OF_PROVIDER)

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/clk/Kconfig            | 1 +
 drivers/clk/clk-fixed-factor.c | 2 +-
 drivers/clk/clk-fixed.c        | 2 +-
 drivers/clk/clk.c              | 2 +-
 drivers/clk/clkdev.c           | 2 +-
 include/linux/clk.h            | 2 +-
 6 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
index 1cf0ccb..dedbf6c 100644
--- a/drivers/clk/Kconfig
+++ b/drivers/clk/Kconfig
@@ -10,6 +10,7 @@ config COMMON_CLK
 
 config COMMON_CLK_OF_PROVIDER
 	bool
+	depends on OFTREE
 	help
 	  Clock driver provides OF-Tree based clock lookup.
 
diff --git a/drivers/clk/clk-fixed-factor.c b/drivers/clk/clk-fixed-factor.c
index 40b63d6..a3dbf33 100644
--- a/drivers/clk/clk-fixed-factor.c
+++ b/drivers/clk/clk-fixed-factor.c
@@ -93,7 +93,7 @@ struct clk *clk_fixed_factor(const char *name,
 	return &f->clk;
 }
 
-#if defined(CONFIG_OFTREE) && defined(CONFIG_COMMON_CLK_OF_PROVIDER)
+#if defined(CONFIG_COMMON_CLK_OF_PROVIDER)
 /**
  * of_fixed_factor_clk_setup() - Setup function for simple fixed factor clock
  */
diff --git a/drivers/clk/clk-fixed.c b/drivers/clk/clk-fixed.c
index 8164005..f0f7fba 100644
--- a/drivers/clk/clk-fixed.c
+++ b/drivers/clk/clk-fixed.c
@@ -55,7 +55,7 @@ struct clk *clk_fixed(const char *name, int rate)
 	return &fix->clk;
 }
 
-#if defined(CONFIG_OFTREE) && defined(CONFIG_COMMON_CLK_OF_PROVIDER)
+#if defined(CONFIG_COMMON_CLK_OF_PROVIDER)
 /**
  * of_fixed_clk_setup() - Setup function for simple fixed rate clock
  */
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 9189521..5bb147e 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -346,7 +346,7 @@ int clk_parent_set_rate(struct clk *clk, unsigned long rate,
 	return clk_set_rate(clk_get_parent(clk), rate);
 }
 
-#if defined(CONFIG_OFTREE) && defined(CONFIG_COMMON_CLK_OF_PROVIDER)
+#if defined(CONFIG_COMMON_CLK_OF_PROVIDER)
 /**
  * struct of_clk_provider - Clock provider registration structure
  * @link: Entry in global list of clock providers
diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c
index 1bc5c6d..7f9f8f2 100644
--- a/drivers/clk/clkdev.c
+++ b/drivers/clk/clkdev.c
@@ -24,7 +24,7 @@
 
 static LIST_HEAD(clocks);
 
-#if defined(CONFIG_OFTREE) && defined(CONFIG_COMMON_CLK_OF_PROVIDER)
+#if defined(CONFIG_COMMON_CLK_OF_PROVIDER)
 struct clk *of_clk_get(struct device_node *np, int index)
 {
 	struct of_phandle_args clkspec;
diff --git a/include/linux/clk.h b/include/linux/clk.h
index f73b029..a061398 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -329,7 +329,7 @@ const struct of_device_id __clk_of_table_##name				\
 __attribute__ ((unused,section (".__clk_of_table"))) \
 	= { .compatible = compat, .data = fn }
 
-#if defined(CONFIG_OFTREE) && defined(CONFIG_COMMON_CLK_OF_PROVIDER)
+#if defined(CONFIG_COMMON_CLK_OF_PROVIDER)
 int of_clk_add_provider(struct device_node *np,
 			struct clk *(*clk_src_get)(struct of_phandle_args *args,
 						   void *data),
-- 
2.9.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH 08/20] clk: No-op CLK_OF_DECLARE if not enabled
  2017-03-08 22:08 [PATCH 00/20] AT91, at91sam9x5ek updates (part I/III) Andrey Smirnov
                   ` (6 preceding siblings ...)
  2017-03-08 22:08 ` [PATCH 07/20] clk: Make COMMON_CLK_OF_PROVIDER depend on OFTREE Andrey Smirnov
@ 2017-03-08 22:08 ` Andrey Smirnov
  2017-03-09 10:54   ` Sascha Hauer
  2017-03-08 22:08 ` [PATCH 09/20] of: base: Use scoring in DT device matching Andrey Smirnov
                   ` (12 subsequent siblings)
  20 siblings, 1 reply; 23+ messages in thread
From: Andrey Smirnov @ 2017-03-08 22:08 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Instead of wrapping each defenition of CLK_OF_DECLARE hook with
preprocessor guards, change the definition of CLK_OF_DECLARE to expand
into no-op if COMMON_CLK_OF_PROVIDER is not enabled.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/clk/clk-fixed-factor.c | 2 --
 drivers/clk/clk-fixed.c        | 3 +--
 include/linux/clk.h            | 6 +++++-
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/clk/clk-fixed-factor.c b/drivers/clk/clk-fixed-factor.c
index a3dbf33..0be4855 100644
--- a/drivers/clk/clk-fixed-factor.c
+++ b/drivers/clk/clk-fixed-factor.c
@@ -93,7 +93,6 @@ struct clk *clk_fixed_factor(const char *name,
 	return &f->clk;
 }
 
-#if defined(CONFIG_COMMON_CLK_OF_PROVIDER)
 /**
  * of_fixed_factor_clk_setup() - Setup function for simple fixed factor clock
  */
@@ -127,4 +126,3 @@ static int of_fixed_factor_clk_setup(struct device_node *node)
 }
 CLK_OF_DECLARE(fixed_factor_clk, "fixed-factor-clock",
 		of_fixed_factor_clk_setup);
-#endif
diff --git a/drivers/clk/clk-fixed.c b/drivers/clk/clk-fixed.c
index f0f7fba..9fa9a93 100644
--- a/drivers/clk/clk-fixed.c
+++ b/drivers/clk/clk-fixed.c
@@ -55,7 +55,6 @@ struct clk *clk_fixed(const char *name, int rate)
 	return &fix->clk;
 }
 
-#if defined(CONFIG_COMMON_CLK_OF_PROVIDER)
 /**
  * of_fixed_clk_setup() - Setup function for simple fixed rate clock
  */
@@ -76,4 +75,4 @@ static int of_fixed_clk_setup(struct device_node *node)
 	return of_clk_add_provider(node, of_clk_src_simple_get, clk);
 }
 CLK_OF_DECLARE(fixed_clk, "fixed-clock", of_fixed_clk_setup);
-#endif
+
diff --git a/include/linux/clk.h b/include/linux/clk.h
index a061398..f705532 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -324,12 +324,13 @@ struct clk *clk_register_composite(const char *name,
 struct device_node;
 struct of_phandle_args;
 
+#if defined(CONFIG_COMMON_CLK_OF_PROVIDER)
+
 #define CLK_OF_DECLARE(name, compat, fn)				\
 const struct of_device_id __clk_of_table_##name				\
 __attribute__ ((unused,section (".__clk_of_table"))) \
 	= { .compatible = compat, .data = fn }
 
-#if defined(CONFIG_COMMON_CLK_OF_PROVIDER)
 int of_clk_add_provider(struct device_node *np,
 			struct clk *(*clk_src_get)(struct of_phandle_args *args,
 						   void *data),
@@ -354,6 +355,9 @@ int of_clk_parent_fill(struct device_node *np, const char **parents,
 		       unsigned int size);
 int of_clk_init(struct device_node *root, const struct of_device_id *matches);
 #else
+
+#define CLK_OF_DECLARE(name, compat, fn)
+
 static inline struct clk *of_clk_get(struct device_node *np, int index)
 {
 	return ERR_PTR(-ENOENT);
-- 
2.9.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH 09/20] of: base: Use scoring in DT device matching
  2017-03-08 22:08 [PATCH 00/20] AT91, at91sam9x5ek updates (part I/III) Andrey Smirnov
                   ` (7 preceding siblings ...)
  2017-03-08 22:08 ` [PATCH 08/20] clk: No-op CLK_OF_DECLARE if not enabled Andrey Smirnov
@ 2017-03-08 22:08 ` Andrey Smirnov
  2017-03-08 22:08 ` [PATCH 10/20] serial: atmel: Check result of clk_get() Andrey Smirnov
                   ` (11 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: Andrey Smirnov @ 2017-03-08 22:08 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Port Linux kernel algorithm for both of_device_is_compatible() and
of_match_node(). With this change former now returns a score on the
scale of 0 to INT_MAX/2, and the latter goes through all compatiblity
entries and selects the entry that has the best matching score.

This is needed for SoCs where IP blocks are backwards compatible and
corresponding OF nodes can proclaim compatibility with several entries
found in driver's compatiblity table. One such example would be PIO
pinctrl block on AT91SAM9x5 SoCs which declare compatibility with with
both "atmel,at91sam9x5-pinctrl" and "atmel,at91rm9200-pinctrl".

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/of/base.c | 37 +++++++++++++++++++++----------------
 1 file changed, 21 insertions(+), 16 deletions(-)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index 0c20fcd..bef8f1d 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -472,21 +472,20 @@ EXPORT_SYMBOL(of_get_cpu_node);
 int of_device_is_compatible(const struct device_node *device,
 		const char *compat)
 {
+	struct property *prop;
 	const char *cp;
-	int cplen, l;
+	int index = 0, score = 0;
 
-	cp = of_get_property(device, "compatible", &cplen);
-	if (cp == NULL)
-		return 0;
-	while (cplen > 0) {
-		if (of_compat_cmp(cp, compat, strlen(compat)) == 0)
-			return 1;
-		l = strlen(cp) + 1;
-		cp += l;
-		cplen -= l;
+	prop = of_find_property(device, "compatible", NULL);
+	for (cp = of_prop_next_string(prop, NULL); cp;
+	     cp = of_prop_next_string(prop, cp), index++) {
+		if (of_compat_cmp(cp, compat, strlen(compat)) == 0) {
+			score = INT_MAX/2 - (index << 2);
+			break;
+		}
 	}
 
-	return 0;
+	return score;
 }
 EXPORT_SYMBOL(of_device_is_compatible);
 
@@ -602,16 +601,22 @@ EXPORT_SYMBOL(of_find_node_with_property);
 const struct of_device_id *of_match_node(const struct of_device_id *matches,
 					 const struct device_node *node)
 {
+	const struct of_device_id *best_match = NULL;
+	int score, best_score = 0;
+
 	if (!matches || !node)
 		return NULL;
 
-	while (matches->compatible) {
-		if (of_device_is_compatible(node, matches->compatible) == 1)
-			return matches;
-		matches++;
+	for (; matches->compatible; matches++) {
+		score = of_device_is_compatible(node, matches->compatible);
+
+		if (score > best_score) {
+			best_match = matches;
+			best_score = score;
+		}
 	}
 
-	return NULL;
+	return best_match;
 }
 
 /**
-- 
2.9.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH 10/20] serial: atmel: Check result of clk_get()
  2017-03-08 22:08 [PATCH 00/20] AT91, at91sam9x5ek updates (part I/III) Andrey Smirnov
                   ` (8 preceding siblings ...)
  2017-03-08 22:08 ` [PATCH 09/20] of: base: Use scoring in DT device matching Andrey Smirnov
@ 2017-03-08 22:08 ` Andrey Smirnov
  2017-03-08 22:09 ` [PATCH 11/20] usb: ohci-at91: " Andrey Smirnov
                   ` (10 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: Andrey Smirnov @ 2017-03-08 22:08 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/serial/atmel.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/serial/atmel.c b/drivers/serial/atmel.c
index 4e4624e..ab94fd2 100644
--- a/drivers/serial/atmel.c
+++ b/drivers/serial/atmel.c
@@ -403,6 +403,11 @@ static int atmel_serial_init_port(struct console_device *cdev)
 		return -ENOENT;
 
 	uart->clk = clk_get(dev, "usart");
+	if (IS_ERR(uart->clk)) {
+		dev_err(dev, "Failed to get 'usart' clock\n");
+		return PTR_ERR(uart->clk);
+	}
+
 	clk_enable(uart->clk);
 	uart->uartclk = clk_get_rate(uart->clk);
 
-- 
2.9.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH 11/20] usb: ohci-at91: Check result of clk_get()
  2017-03-08 22:08 [PATCH 00/20] AT91, at91sam9x5ek updates (part I/III) Andrey Smirnov
                   ` (9 preceding siblings ...)
  2017-03-08 22:08 ` [PATCH 10/20] serial: atmel: Check result of clk_get() Andrey Smirnov
@ 2017-03-08 22:09 ` Andrey Smirnov
  2017-03-08 22:09 ` [PATCH 12/20] usb: ohci-at91: Convert global variables to private data Andrey Smirnov
                   ` (9 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: Andrey Smirnov @ 2017-03-08 22:09 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/usb/host/ohci-at91.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index 0f5c8f1..ca583ff 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -47,7 +47,16 @@ static int at91_ohci_probe(struct device_d *dev)
 	struct ohci_regs __iomem *regs = (struct ohci_regs __iomem *)dev->resource[0].start;
 
 	iclk = clk_get(NULL, "ohci_clk");
+	if (IS_ERR(iclk)) {
+		dev_err(dev, "Failed to get 'ohci_clk'\n");
+		return PTR_ERR(iclk);
+	}
+
 	fclk = clk_get(NULL, "uhpck");
+	if (IS_ERR(fclk)) {
+		dev_err(dev, "Failed to get 'uhpck'\n");
+		return PTR_ERR(fclk);
+	}
 
 	/*
 	 * Start the USB clocks.
-- 
2.9.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH 12/20] usb: ohci-at91: Convert global variables to private data
  2017-03-08 22:08 [PATCH 00/20] AT91, at91sam9x5ek updates (part I/III) Andrey Smirnov
                   ` (10 preceding siblings ...)
  2017-03-08 22:09 ` [PATCH 11/20] usb: ohci-at91: " Andrey Smirnov
@ 2017-03-08 22:09 ` Andrey Smirnov
  2017-03-08 22:09 ` [PATCH 13/20] usb: ohci-at91: Check result of clk_enable() Andrey Smirnov
                   ` (8 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: Andrey Smirnov @ 2017-03-08 22:09 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Store driver data in per-device private variable as opposed to storing
it in global vairables.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/usb/host/ohci-at91.c | 59 +++++++++++++++++++++++++++-----------------
 1 file changed, 37 insertions(+), 22 deletions(-)

diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index ca583ff..cd7b321 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -27,66 +27,81 @@
 
 #include "ohci.h"
 
-/* interface and function clocks; sometimes also an AHB clock */
-static struct clk *iclk, *fclk;
+struct ohci_at91_priv {
+	struct device_d *dev;
+	struct clk *iclk;
+	struct clk *fclk;
+	struct ohci_regs __iomem *regs;
+};
 
-static void at91_start_clock(void)
+static void at91_start_clock(struct ohci_at91_priv *ohci_at91)
 {
-	clk_enable(iclk);
-	clk_enable(fclk);
+	clk_enable(ohci_at91->iclk);
+	clk_enable(ohci_at91->fclk);
 }
 
-static void at91_stop_clock(void)
+static void at91_stop_clock(struct ohci_at91_priv *ohci_at91)
 {
-	clk_disable(fclk);
-	clk_disable(iclk);
+	clk_disable(ohci_at91->fclk);
+	clk_disable(ohci_at91->iclk);
 }
 
 static int at91_ohci_probe(struct device_d *dev)
 {
-	struct ohci_regs __iomem *regs = (struct ohci_regs __iomem *)dev->resource[0].start;
+	struct resource *io;
+	struct ohci_at91_priv *ohci_at91 = xzalloc(sizeof(*ohci_at91));
+
+	dev->priv = ohci_at91;
+	ohci_at91->dev = dev;
+
+	io = dev_get_resource(dev, IORESOURCE_MEM, 0);
+	if (IS_ERR(io)) {
+		dev_err(dev, "Failed to get IORESOURCE_MEM\n");
+		return PTR_ERR(io);
+	}
+	ohci_at91->regs = IOMEM(io->start);
 
-	iclk = clk_get(NULL, "ohci_clk");
-	if (IS_ERR(iclk)) {
+	ohci_at91->iclk = clk_get(NULL, "ohci_clk");
+	if (IS_ERR(ohci_at91->iclk)) {
 		dev_err(dev, "Failed to get 'ohci_clk'\n");
-		return PTR_ERR(iclk);
+		return PTR_ERR(ohci_at91->iclk);
 	}
 
-	fclk = clk_get(NULL, "uhpck");
-	if (IS_ERR(fclk)) {
+	ohci_at91->fclk = clk_get(NULL, "uhpck");
+	if (IS_ERR(ohci_at91->fclk)) {
 		dev_err(dev, "Failed to get 'uhpck'\n");
-		return PTR_ERR(fclk);
+		return PTR_ERR(ohci_at91->fclk);
 	}
 
 	/*
 	 * Start the USB clocks.
 	 */
-	at91_start_clock();
+	at91_start_clock(ohci_at91);
 
 	/*
 	 * The USB host controller must remain in reset.
 	 */
-	writel(0, &regs->control);
+	writel(0, &ohci_at91->regs->control);
 
-	add_generic_device("ohci", DEVICE_ID_DYNAMIC, NULL, dev->resource[0].start,
-			   resource_size(&dev->resource[0]), IORESOURCE_MEM, NULL);
+	add_generic_device("ohci", DEVICE_ID_DYNAMIC, NULL, io->start,
+			   resource_size(io), IORESOURCE_MEM, NULL);
 
 	return 0;
 }
 
 static void at91_ohci_remove(struct device_d *dev)
 {
-	struct ohci_regs __iomem *regs = (struct ohci_regs __iomem *)dev->resource[0].start;
+	struct ohci_at91_priv *ohci_at91 = dev->priv;
 
 	/*
 	 * Put the USB host controller into reset.
 	 */
-	writel(0, &regs->control);
+	writel(0, &ohci_at91->regs->control);
 
 	/*
 	 * Stop the USB clocks.
 	 */
-	at91_stop_clock();
+	at91_stop_clock(ohci_at91);
 }
 
 static struct driver_d at91_ohci_driver = {
-- 
2.9.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH 13/20] usb: ohci-at91: Check result of clk_enable()
  2017-03-08 22:08 [PATCH 00/20] AT91, at91sam9x5ek updates (part I/III) Andrey Smirnov
                   ` (11 preceding siblings ...)
  2017-03-08 22:09 ` [PATCH 12/20] usb: ohci-at91: Convert global variables to private data Andrey Smirnov
@ 2017-03-08 22:09 ` Andrey Smirnov
  2017-03-08 22:09 ` [PATCH 14/20] usb: ehci-atmel: " Andrey Smirnov
                   ` (7 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: Andrey Smirnov @ 2017-03-08 22:09 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/usb/host/ohci-at91.c | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index cd7b321..5f74526 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -34,10 +34,23 @@ struct ohci_at91_priv {
 	struct ohci_regs __iomem *regs;
 };
 
-static void at91_start_clock(struct ohci_at91_priv *ohci_at91)
+static int at91_start_clock(struct ohci_at91_priv *ohci_at91)
 {
-	clk_enable(ohci_at91->iclk);
-	clk_enable(ohci_at91->fclk);
+	int ret;
+
+	ret = clk_enable(ohci_at91->iclk);
+	if (ret < 0) {
+		dev_err(ohci_at91->dev, "Failed to enable 'iclk'\n");
+		return ret;
+	}
+
+	ret = clk_enable(ohci_at91->fclk);
+	if (ret < 0) {
+		dev_err(ohci_at91->dev, "Failed to enable 'fclk'\n");
+		return ret;
+	}
+
+	return 0;
 }
 
 static void at91_stop_clock(struct ohci_at91_priv *ohci_at91)
@@ -48,6 +61,7 @@ static void at91_stop_clock(struct ohci_at91_priv *ohci_at91)
 
 static int at91_ohci_probe(struct device_d *dev)
 {
+	int ret;
 	struct resource *io;
 	struct ohci_at91_priv *ohci_at91 = xzalloc(sizeof(*ohci_at91));
 
@@ -76,7 +90,9 @@ static int at91_ohci_probe(struct device_d *dev)
 	/*
 	 * Start the USB clocks.
 	 */
-	at91_start_clock(ohci_at91);
+	ret = at91_start_clock(ohci_at91);
+	if (ret < 0)
+		return ret;
 
 	/*
 	 * The USB host controller must remain in reset.
-- 
2.9.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH 14/20] usb: ehci-atmel: Check result of clk_enable()
  2017-03-08 22:08 [PATCH 00/20] AT91, at91sam9x5ek updates (part I/III) Andrey Smirnov
                   ` (12 preceding siblings ...)
  2017-03-08 22:09 ` [PATCH 13/20] usb: ohci-at91: Check result of clk_enable() Andrey Smirnov
@ 2017-03-08 22:09 ` Andrey Smirnov
  2017-03-08 22:09 ` [PATCH 15/20] usb: echi-atmel: Convert global variables to private data Andrey Smirnov
                   ` (6 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: Andrey Smirnov @ 2017-03-08 22:09 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/usb/host/ehci-atmel.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/host/ehci-atmel.c b/drivers/usb/host/ehci-atmel.c
index cc9636c..fa9ca7d 100644
--- a/drivers/usb/host/ehci-atmel.c
+++ b/drivers/usb/host/ehci-atmel.c
@@ -32,10 +32,20 @@
 /* interface and function clocks; sometimes also an AHB clock */
 static struct clk *iclk, *fclk;
 
-static void atmel_start_clock(void)
+static int atmel_start_clock(void)
 {
-	clk_enable(iclk);
-	clk_enable(fclk);
+	int ret;
+	ret = clk_enable(iclk);
+	if (ret < 0) {
+		pr_err("Error enabling interface clock\n");
+		return ret;
+	}
+
+	ret = clk_enable(fclk);
+	if (ret < 0)
+		pr_err("Error enabling function clock\n");
+
+	return ret;
 }
 
 static void atmel_stop_clock(void)
@@ -46,6 +56,7 @@ static void atmel_stop_clock(void)
 
 static int atmel_ehci_probe(struct device_d *dev)
 {
+	int ret;
 	struct resource *iores;
 	struct ehci_data data;
 
@@ -64,7 +75,9 @@ static int atmel_ehci_probe(struct device_d *dev)
 	/*
 	 * Start the USB clocks.
 	 */
-	atmel_start_clock();
+	ret = atmel_start_clock();
+	if (ret < 0)
+		return ret;
 
 	data.flags = 0;
 
-- 
2.9.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH 15/20] usb: echi-atmel: Convert global variables to private data
  2017-03-08 22:08 [PATCH 00/20] AT91, at91sam9x5ek updates (part I/III) Andrey Smirnov
                   ` (13 preceding siblings ...)
  2017-03-08 22:09 ` [PATCH 14/20] usb: ehci-atmel: " Andrey Smirnov
@ 2017-03-08 22:09 ` Andrey Smirnov
  2017-03-08 22:09 ` [PATCH 16/20] usb: ehci-atmel: Zero ehci_data before using it Andrey Smirnov
                   ` (5 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: Andrey Smirnov @ 2017-03-08 22:09 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/usb/host/ehci-atmel.c | 42 ++++++++++++++++++++++++++----------------
 1 file changed, 26 insertions(+), 16 deletions(-)

diff --git a/drivers/usb/host/ehci-atmel.c b/drivers/usb/host/ehci-atmel.c
index fa9ca7d..7a9d942 100644
--- a/drivers/usb/host/ehci-atmel.c
+++ b/drivers/usb/host/ehci-atmel.c
@@ -29,29 +29,34 @@
 
 #include "ehci.h"
 
-/* interface and function clocks; sometimes also an AHB clock */
-static struct clk *iclk, *fclk;
+struct atmel_ehci_priv {
+	struct device_d *dev;
+	struct clk *iclk;
+	struct clk *uclk;
+};
 
-static int atmel_start_clock(void)
+static int atmel_start_clock(struct atmel_ehci_priv *atehci)
 {
 	int ret;
-	ret = clk_enable(iclk);
+	ret = clk_enable(atehci->iclk);
 	if (ret < 0) {
-		pr_err("Error enabling interface clock\n");
+		dev_err(atehci->dev,
+			"Error enabling interface clock\n");
 		return ret;
 	}
 
-	ret = clk_enable(fclk);
+	ret = clk_enable(atehci->uclk);
 	if (ret < 0)
-		pr_err("Error enabling function clock\n");
+		dev_err(atehci->dev,
+			"Error enabling function clock\n");
 
 	return ret;
 }
 
-static void atmel_stop_clock(void)
+static void atmel_stop_clock(struct atmel_ehci_priv *atehci)
 {
-	clk_disable(fclk);
-	clk_disable(iclk);
+	clk_disable(atehci->iclk);
+	clk_disable(atehci->uclk);
 }
 
 static int atmel_ehci_probe(struct device_d *dev)
@@ -59,15 +64,20 @@ static int atmel_ehci_probe(struct device_d *dev)
 	int ret;
 	struct resource *iores;
 	struct ehci_data data;
+	struct atmel_ehci_priv *atehci;
+
+	atehci = xzalloc(sizeof(*atehci));
+	atehci->dev = dev;
+	dev->priv = atehci;
 
-	iclk = clk_get(dev, "ehci_clk");
-	if (IS_ERR(iclk)) {
+	atehci->iclk = clk_get(dev, "ehci_clk");
+	if (IS_ERR(atehci->iclk)) {
 		dev_err(dev, "Error getting interface clock\n");
 		return -ENOENT;
 	}
 
-	fclk = clk_get(dev, "uhpck");
-	if (IS_ERR(fclk)) {
+	atehci->uclk = clk_get(dev, "uhpck");
+	if (IS_ERR(atehci->iclk)) {
 		dev_err(dev, "Error getting function clock\n");
 		return -ENOENT;
 	}
@@ -75,7 +85,7 @@ static int atmel_ehci_probe(struct device_d *dev)
 	/*
 	 * Start the USB clocks.
 	 */
-	ret = atmel_start_clock();
+	ret = atmel_start_clock(atehci);
 	if (ret < 0)
 		return ret;
 
@@ -96,7 +106,7 @@ static void atmel_ehci_remove(struct device_d *dev)
 	/*
 	 * Stop the USB clocks.
 	 */
-	atmel_stop_clock();
+	atmel_stop_clock(dev->priv);
 }
 
 static struct driver_d atmel_ehci_driver = {
-- 
2.9.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH 16/20] usb: ehci-atmel: Zero ehci_data before using it
  2017-03-08 22:08 [PATCH 00/20] AT91, at91sam9x5ek updates (part I/III) Andrey Smirnov
                   ` (14 preceding siblings ...)
  2017-03-08 22:09 ` [PATCH 15/20] usb: echi-atmel: Convert global variables to private data Andrey Smirnov
@ 2017-03-08 22:09 ` Andrey Smirnov
  2017-03-08 22:09 ` [PATCH 17/20] usb: echi-atmel: Check result of ehci_register() Andrey Smirnov
                   ` (4 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: Andrey Smirnov @ 2017-03-08 22:09 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Zero ehci_data before using it as an argument for echi_register,
otherwise bogus values (some of which are interpreted as callbacks) will
be passed through, resulting in illegal memory accesses.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/usb/host/ehci-atmel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/host/ehci-atmel.c b/drivers/usb/host/ehci-atmel.c
index 7a9d942..4b9fc0a 100644
--- a/drivers/usb/host/ehci-atmel.c
+++ b/drivers/usb/host/ehci-atmel.c
@@ -89,7 +89,7 @@ static int atmel_ehci_probe(struct device_d *dev)
 	if (ret < 0)
 		return ret;
 
-	data.flags = 0;
+	memset(&data, 0, sizeof(data));
 
 	iores = dev_request_mem_resource(dev, 0);
 	if (IS_ERR(iores))
-- 
2.9.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH 17/20] usb: echi-atmel: Check result of ehci_register()
  2017-03-08 22:08 [PATCH 00/20] AT91, at91sam9x5ek updates (part I/III) Andrey Smirnov
                   ` (15 preceding siblings ...)
  2017-03-08 22:09 ` [PATCH 16/20] usb: ehci-atmel: Zero ehci_data before using it Andrey Smirnov
@ 2017-03-08 22:09 ` Andrey Smirnov
  2017-03-08 22:09 ` [PATCH 18/20] spi: atmel_spi: Configure CS GPIO as output Andrey Smirnov
                   ` (3 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: Andrey Smirnov @ 2017-03-08 22:09 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/usb/host/ehci-atmel.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/usb/host/ehci-atmel.c b/drivers/usb/host/ehci-atmel.c
index 4b9fc0a..f075b50 100644
--- a/drivers/usb/host/ehci-atmel.c
+++ b/drivers/usb/host/ehci-atmel.c
@@ -96,9 +96,7 @@ static int atmel_ehci_probe(struct device_d *dev)
 		return PTR_ERR(iores);
 	data.hccr = IOMEM(iores->start);
 
-	ehci_register(dev, &data);
-
-	return 0;
+	return ehci_register(dev, &data);
 }
 
 static void atmel_ehci_remove(struct device_d *dev)
-- 
2.9.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH 18/20] spi: atmel_spi: Configure CS GPIO as output
  2017-03-08 22:08 [PATCH 00/20] AT91, at91sam9x5ek updates (part I/III) Andrey Smirnov
                   ` (16 preceding siblings ...)
  2017-03-08 22:09 ` [PATCH 17/20] usb: echi-atmel: Check result of ehci_register() Andrey Smirnov
@ 2017-03-08 22:09 ` Andrey Smirnov
  2017-03-08 22:09 ` [PATCH 19/20] spi: atmel_spi: Use VERSION register instead of CPU type Andrey Smirnov
                   ` (2 subsequent siblings)
  20 siblings, 0 replies; 23+ messages in thread
From: Andrey Smirnov @ 2017-03-08 22:09 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

On AT91 GPIOs default to being inputs, so we need to explicitly
configure CS gpio to being an output.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/spi/atmel_spi.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c
index 3f2c527..67028e6 100644
--- a/drivers/spi/atmel_spi.c
+++ b/drivers/spi/atmel_spi.c
@@ -172,6 +172,8 @@ static int atmel_spi_setup(struct spi_device *spi)
 	struct spi_master	*master = spi->master;
 	struct atmel_spi	*as = to_atmel_spi(master);
 
+	int			npcs_pin;
+	unsigned		active = spi->mode & SPI_CS_HIGH;
 	u32			scbr, csr;
 	unsigned int		bits = spi->bits_per_word;
 	unsigned long		bus_hz;
@@ -183,6 +185,8 @@ static int atmel_spi_setup(struct spi_device *spi)
 		return -EINVAL;
 	}
 
+	npcs_pin = as->cs_pins[spi->chip_select];
+
 	if (bits < 8 || bits > 16) {
 		dev_dbg(&spi->dev,
 				"setup: invalid bits_per_word %u (8 to 16)\n",
@@ -235,7 +239,7 @@ static int atmel_spi_setup(struct spi_device *spi)
 	csr |= SPI_BF(DLYBS, 0);
 	csr |= SPI_BF(DLYBCT, 0);
 
-	/* gpio_direction_output(npcs_pin, !(spi->mode & SPI_CS_HIGH)); */
+	gpio_direction_output(npcs_pin, !active);
 	dev_dbg(master->dev,
 		"setup: %lu Hz bpw %u mode 0x%x -> csr%d %08x\n",
 		bus_hz / scbr, bits, spi->mode, spi->chip_select, csr);
-- 
2.9.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH 19/20] spi: atmel_spi: Use VERSION register instead of CPU type
  2017-03-08 22:08 [PATCH 00/20] AT91, at91sam9x5ek updates (part I/III) Andrey Smirnov
                   ` (17 preceding siblings ...)
  2017-03-08 22:09 ` [PATCH 18/20] spi: atmel_spi: Configure CS GPIO as output Andrey Smirnov
@ 2017-03-08 22:09 ` Andrey Smirnov
  2017-03-08 22:09 ` [PATCH 20/20] clocksource: at91: Move to 'drivers/clocksource' Andrey Smirnov
  2017-03-09  7:19 ` [PATCH 00/20] AT91, at91sam9x5ek updates (part I/III) Sascha Hauer
  20 siblings, 0 replies; 23+ messages in thread
From: Andrey Smirnov @ 2017-03-08 22:09 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Use VERSION register instead of CPU type to determine IP block's version
and capabilities. This what corresponding Linux kernel driver does.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/spi/atmel_spi.c | 35 +++++++++++++++++++++++++++++------
 drivers/spi/atmel_spi.h |  1 +
 2 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c
index 67028e6..ef57867 100644
--- a/drivers/spi/atmel_spi.c
+++ b/drivers/spi/atmel_spi.c
@@ -40,11 +40,16 @@
 
 #include "atmel_spi.h"
 
+struct atmel_spi_caps {
+	bool	is_spi2;
+};
+
 struct atmel_spi {
 	struct spi_master	master;
 	void __iomem		*regs;
 	struct clk		*clk;
 	int			*cs_pins;
+	struct atmel_spi_caps	caps;
 };
 
 #define to_atmel_spi(p)		container_of(p, struct atmel_spi, master)
@@ -62,9 +67,9 @@ struct atmel_spi {
  * register, but I haven't checked that it exists on all chips, and
  * this is cheaper anyway.
  */
-static inline bool atmel_spi_is_v2(void)
+static inline bool atmel_spi_is_v2(struct atmel_spi *as)
 {
-	return !cpu_is_at91rm9200();
+	return as->caps.is_spi2;
 }
 
 /*
@@ -104,7 +109,7 @@ static void cs_activate(struct atmel_spi *as, struct spi_device *spi)
 
 	csr = (u32)spi->controller_data;
 
-	if (atmel_spi_is_v2()) {
+	if (atmel_spi_is_v2(as)) {
 		/*
 		 * Always use CSR0. This ensures that the clock
 		 * switches to the correct idle polarity before we
@@ -163,8 +168,9 @@ static void cs_deactivate(struct atmel_spi *as, struct spi_device *spi)
 			npcs_pin, active ? " (low)" : "",
 			mr);
 
-	if (atmel_spi_is_v2() || npcs_pin != AT91_PIN_PA3)
+	if (atmel_spi_is_v2(as) || npcs_pin != AT91_PIN_PA3) {
 		gpio_set_value(npcs_pin, !active);
+	}
 }
 
 static int atmel_spi_setup(struct spi_device *spi)
@@ -199,7 +205,7 @@ static int atmel_spi_setup(struct spi_device *spi)
 			spi->max_speed_hz);
 
 	bus_hz = clk_get_rate(as->clk);
-	if (!atmel_spi_is_v2())
+	if (!atmel_spi_is_v2(as))
 		bus_hz /= 2;
 
 	if (spi->max_speed_hz) {
@@ -248,7 +254,7 @@ static int atmel_spi_setup(struct spi_device *spi)
 
 	cs_deactivate(as, spi);
 
-	if (!atmel_spi_is_v2())
+	if (!atmel_spi_is_v2(as))
 		spi_writel(as, CSR0 + 4 * spi->chip_select, csr);
 
 	return 0;
@@ -373,6 +379,21 @@ err:
 	return ret;
 }
 
+static inline unsigned int atmel_get_version(struct atmel_spi *as)
+{
+	return spi_readl(as, VERSION) & 0x00000fff;
+}
+
+static void atmel_get_caps(struct atmel_spi *as)
+{
+	unsigned int version;
+
+	version = atmel_get_version(as);
+	dev_info(as->master.dev, "version: 0x%x\n", version);
+
+	as->caps.is_spi2 = version > 0x121;
+}
+
 static int atmel_spi_probe(struct device_d *dev)
 {
 	struct resource *iores;
@@ -409,6 +430,8 @@ static int atmel_spi_probe(struct device_d *dev)
 		return PTR_ERR(iores);
 	as->regs = IOMEM(iores->start);
 
+	atmel_get_caps(as);
+
 	for (i = 0; i < master->num_chipselect; i++) {
 		ret = gpio_request(as->cs_pins[i], dev_name(dev));
 		if (ret)
diff --git a/drivers/spi/atmel_spi.h b/drivers/spi/atmel_spi.h
index 38ce119..3f4d7ba 100644
--- a/drivers/spi/atmel_spi.h
+++ b/drivers/spi/atmel_spi.h
@@ -23,6 +23,7 @@
 #define SPI_CSR1				0x0034
 #define SPI_CSR2				0x0038
 #define SPI_CSR3				0x003c
+#define SPI_VERSION				0x00fc
 #define SPI_RPR					0x0100
 #define SPI_RCR					0x0104
 #define SPI_TPR					0x0108
-- 
2.9.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH 20/20] clocksource: at91: Move to 'drivers/clocksource'
  2017-03-08 22:08 [PATCH 00/20] AT91, at91sam9x5ek updates (part I/III) Andrey Smirnov
                   ` (18 preceding siblings ...)
  2017-03-08 22:09 ` [PATCH 19/20] spi: atmel_spi: Use VERSION register instead of CPU type Andrey Smirnov
@ 2017-03-08 22:09 ` Andrey Smirnov
  2017-03-09  7:19 ` [PATCH 00/20] AT91, at91sam9x5ek updates (part I/III) Sascha Hauer
  20 siblings, 0 replies; 23+ messages in thread
From: Andrey Smirnov @ 2017-03-08 22:09 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Move PIT driver code to 'drivers/clocsource' and accomodate it by
adjusting Kconfig variables. Rename the file to 'timer-atmel-pit.c' to
re-align the driver with code in Linux kernel.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 arch/arm/mach-at91/Kconfig                                         | 7 ++-----
 arch/arm/mach-at91/Makefile                                        | 1 -
 drivers/clocksource/Kconfig                                        | 4 ++++
 drivers/clocksource/Makefile                                       | 1 +
 .../at91sam926x_time.c => drivers/clocksource/timer-atmel-pit.c    | 0
 5 files changed, 7 insertions(+), 6 deletions(-)
 rename arch/arm/mach-at91/at91sam926x_time.c => drivers/clocksource/timer-atmel-pit.c (100%)

diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index c45fc4d..2d4721a 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -15,20 +15,17 @@ config HAVE_AT91_LOWLEVEL_INIT
 config AT91SAM9_SMC
 	bool
 
-config AT91SAM9_TIMER
-	bool
-
 config SOC_AT91SAM9
 	bool
 	select CPU_ARM926T
 	select AT91SAM9_SMC
-	select AT91SAM9_TIMER
+	select CLOCKSOURCE_ATMEL_PIT
 
 config SOC_SAMA5
 	bool
 	select CPU_V7
 	select AT91SAM9_SMC
-	select AT91SAM9_TIMER
+	select CLOCKSOURCE_ATMEL_PIT
 
 config ARCH_TEXT_BASE
 	hex
diff --git a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile
index c2991b0..1f63b09 100644
--- a/arch/arm/mach-at91/Makefile
+++ b/arch/arm/mach-at91/Makefile
@@ -19,7 +19,6 @@ obj-$(CONFIG_AT91SAM9_RESET) += at91sam9_reset.o
 obj-$(CONFIG_AT91SAM9G45_RESET) += at91sam9g45_reset.o
 
 obj-$(CONFIG_AT91SAM9_SMC) += sam9_smc.o
-obj-$(CONFIG_AT91SAM9_TIMER) += at91sam926x_time.o
 
 # CPU-specific support
 obj-$(CONFIG_ARCH_AT91RM9200)	+= at91rm9200.o at91rm9200_time.o at91rm9200_devices.o
diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
index f1ab554..f3c3255 100644
--- a/drivers/clocksource/Kconfig
+++ b/drivers/clocksource/Kconfig
@@ -53,3 +53,7 @@ config CLOCKSOURCE_UEMD
 config CLOCKSOURCE_ROCKCHIP
 	bool
 	depends on ARCH_ROCKCHIP
+
+config CLOCKSOURCE_ATMEL_PIT
+       bool
+       depends on SOC_AT91SAM9 || SOC_SAMA5
diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
index 39982ff..0564d8f 100644
--- a/drivers/clocksource/Makefile
+++ b/drivers/clocksource/Makefile
@@ -8,3 +8,4 @@ obj-$(CONFIG_CLOCKSOURCE_NOMADIK) += nomadik.o
 obj-$(CONFIG_CLOCKSOURCE_ORION)   += orion.o
 obj-$(CONFIG_CLOCKSOURCE_UEMD)    += uemd.o
 obj-$(CONFIG_CLOCKSOURCE_ROCKCHIP)+= rk_timer.o
+obj-$(CONFIG_CLOCKSOURCE_ATMEL_PIT) += timer-atmel-pit.o
diff --git a/arch/arm/mach-at91/at91sam926x_time.c b/drivers/clocksource/timer-atmel-pit.c
similarity index 100%
rename from arch/arm/mach-at91/at91sam926x_time.c
rename to drivers/clocksource/timer-atmel-pit.c
-- 
2.9.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 00/20] AT91, at91sam9x5ek updates (part I/III)
  2017-03-08 22:08 [PATCH 00/20] AT91, at91sam9x5ek updates (part I/III) Andrey Smirnov
                   ` (19 preceding siblings ...)
  2017-03-08 22:09 ` [PATCH 20/20] clocksource: at91: Move to 'drivers/clocksource' Andrey Smirnov
@ 2017-03-09  7:19 ` Sascha Hauer
  20 siblings, 0 replies; 23+ messages in thread
From: Sascha Hauer @ 2017-03-09  7:19 UTC (permalink / raw)
  To: Andrey Smirnov; +Cc: barebox

On Wed, Mar 08, 2017 at 02:08:49PM -0800, Andrey Smirnov wrote:
> Hi everone,
> 
> As discussed in original thread [1], here is a first batch of AT91
> related patches. The patches gathered in this set are bugfixes, port
> of functionality form Linux or code refactoring.
> 
> Feedback from Sascha and Sam has been incorporated, but other than
> that the code should be as it was in [1].
> 
> Any feedback is appreciated.

Applied, thanks

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 08/20] clk: No-op CLK_OF_DECLARE if not enabled
  2017-03-08 22:08 ` [PATCH 08/20] clk: No-op CLK_OF_DECLARE if not enabled Andrey Smirnov
@ 2017-03-09 10:54   ` Sascha Hauer
  0 siblings, 0 replies; 23+ messages in thread
From: Sascha Hauer @ 2017-03-09 10:54 UTC (permalink / raw)
  To: Andrey Smirnov; +Cc: barebox

Hi Andrey,

On Wed, Mar 08, 2017 at 02:08:57PM -0800, Andrey Smirnov wrote:
> Instead of wrapping each defenition of CLK_OF_DECLARE hook with
> preprocessor guards, change the definition of CLK_OF_DECLARE to expand
> into no-op if COMMON_CLK_OF_PROVIDER is not enabled.
> 
> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
> ---
>  drivers/clk/clk-fixed-factor.c | 2 --
>  drivers/clk/clk-fixed.c        | 3 +--
>  include/linux/clk.h            | 6 +++++-
>  3 files changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/clk/clk-fixed-factor.c b/drivers/clk/clk-fixed-factor.c
> index a3dbf33..0be4855 100644
> --- a/drivers/clk/clk-fixed-factor.c
> +++ b/drivers/clk/clk-fixed-factor.c
> @@ -93,7 +93,6 @@ struct clk *clk_fixed_factor(const char *name,
>  	return &f->clk;
>  }
>  
> -#if defined(CONFIG_COMMON_CLK_OF_PROVIDER)
>  /**
>   * of_fixed_factor_clk_setup() - Setup function for simple fixed factor clock
>   */
> @@ -127,4 +126,3 @@ static int of_fixed_factor_clk_setup(struct device_node *node)
>  }
>  CLK_OF_DECLARE(fixed_factor_clk, "fixed-factor-clock",
>  		of_fixed_factor_clk_setup);
> -#endif

This causes compile breakage when CONFIG_COMMON_CLK_OF_PROVIDER is disabled:

drivers/clk/clk-fixed.c: In function 'of_fixed_clk_setup':
drivers/clk/clk-fixed.c:75:2: error: implicit declaration of function 'of_clk_add_provider' [-Werror=implicit-function-declaration]
drivers/clk/clk-fixed.c:75:35: error: 'of_clk_src_simple_get' undeclared (first use in this function)
drivers/clk/clk-fixed.c:75:35: note: each undeclared identifier is reported only once for each function it appears in
drivers/clk/clk-fixed.c: At top level:
drivers/clk/clk-fixed.c:61:12: warning: 'of_fixed_clk_setup' defined but not used [-Wunused-function]
cc1: some warnings being treated as errors
ICECC[17949] 11:47:35: Compiled on 10.1.0.23
/ptx/work/dude/WORK_A/sha/backup/barebox/barebox/scripts/Makefile.build:249: recipe for target 'drivers/clk/clk-fixed.o' failed
make[3]: *** [drivers/clk/clk-fixed.o] Error 1
make[3]: *** Waiting for unfinished jobs....
  LD      drivers/pinctrl/built-in.o
  CC      drivers/clk/imx/clk-pllv1.o
  CC      drivers/clk/imx/clk-pllv2.o
  CC      drivers/clk/imx/clk-pllv3.o
  CC      drivers/clk/imx/clk-pfd.o
  CC      drivers/clk/imx/clk-gate2.o
  CC      drivers/clk/imx/clk-gate-exclusive.o
  CC      drivers/clk/imx/clk-cpu.o
  CC      drivers/clk/imx/clk.o
  LD      drivers/watchdog/built-in.o
  CC      drivers/clk/imx/clk-imx25.o
drivers/clk/clk-fixed-factor.c: In function 'of_fixed_factor_clk_setup':
drivers/clk/clk-fixed-factor.c:119:2: error: implicit declaration of function 'of_clk_get_parent_name' [-Werror=implicit-function-declaration]
drivers/clk/clk-fixed-factor.c:119:14: warning: assignment makes pointer from integer without a cast
drivers/clk/clk-fixed-factor.c:125:2: error: implicit declaration of function 'of_clk_add_provider' [-Werror=implicit-function-declaration]
drivers/clk/clk-fixed-factor.c:125:35: error: 'of_clk_src_simple_get' undeclared (first use in this function)
drivers/clk/clk-fixed-factor.c:125:35: note: each undeclared identifier is reported only once for each function it appears in
drivers/clk/clk-fixed-factor.c: At top level:
drivers/clk/clk-fixed-factor.c:99:12: warning: 'of_fixed_factor_clk_setup' defined but not used [-Wunused-function]

I dropped this patch for now.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2017-03-09 10:55 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-08 22:08 [PATCH 00/20] AT91, at91sam9x5ek updates (part I/III) Andrey Smirnov
2017-03-08 22:08 ` [PATCH 01/20] at91: Fix bug/typo in debug_ll.h Andrey Smirnov
2017-03-08 22:08 ` [PATCH 02/20] regmap: Implement syscon_node_to_regmap() Andrey Smirnov
2017-03-08 22:08 ` [PATCH 03/20] pinctrl: at91: Fix a bug in at91_pinctrl_set_conf() Andrey Smirnov
2017-03-08 22:08 ` [PATCH 04/20] pinctrl: at91: Fix a bug in at91_pinctrl_set_state() Andrey Smirnov
2017-03-08 22:08 ` [PATCH 05/20] pinctrl: at91: Implement .get_direction hook Andrey Smirnov
2017-03-08 22:08 ` [PATCH 06/20] clk: Port two helper functions from Linux Andrey Smirnov
2017-03-08 22:08 ` [PATCH 07/20] clk: Make COMMON_CLK_OF_PROVIDER depend on OFTREE Andrey Smirnov
2017-03-08 22:08 ` [PATCH 08/20] clk: No-op CLK_OF_DECLARE if not enabled Andrey Smirnov
2017-03-09 10:54   ` Sascha Hauer
2017-03-08 22:08 ` [PATCH 09/20] of: base: Use scoring in DT device matching Andrey Smirnov
2017-03-08 22:08 ` [PATCH 10/20] serial: atmel: Check result of clk_get() Andrey Smirnov
2017-03-08 22:09 ` [PATCH 11/20] usb: ohci-at91: " Andrey Smirnov
2017-03-08 22:09 ` [PATCH 12/20] usb: ohci-at91: Convert global variables to private data Andrey Smirnov
2017-03-08 22:09 ` [PATCH 13/20] usb: ohci-at91: Check result of clk_enable() Andrey Smirnov
2017-03-08 22:09 ` [PATCH 14/20] usb: ehci-atmel: " Andrey Smirnov
2017-03-08 22:09 ` [PATCH 15/20] usb: echi-atmel: Convert global variables to private data Andrey Smirnov
2017-03-08 22:09 ` [PATCH 16/20] usb: ehci-atmel: Zero ehci_data before using it Andrey Smirnov
2017-03-08 22:09 ` [PATCH 17/20] usb: echi-atmel: Check result of ehci_register() Andrey Smirnov
2017-03-08 22:09 ` [PATCH 18/20] spi: atmel_spi: Configure CS GPIO as output Andrey Smirnov
2017-03-08 22:09 ` [PATCH 19/20] spi: atmel_spi: Use VERSION register instead of CPU type Andrey Smirnov
2017-03-08 22:09 ` [PATCH 20/20] clocksource: at91: Move to 'drivers/clocksource' Andrey Smirnov
2017-03-09  7:19 ` [PATCH 00/20] AT91, at91sam9x5ek updates (part I/III) Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox