Skip to contentSkip to conversation

bcm2835: auxiliar device support for spi

PATCH In review [email protected] 5 participants 15 messages Sep 4, 2015 – Sep 10, 2015

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

v5 cover bcm2835: auxiliar device support for spi

From: Martin Sperl <[email protected]>

The BCM2835 contains 3 auxiliar devices:
* spi1
* spi2
* uart1

All of those 3 devices are enabled/disabled via a shared register, which is set by default to be disabled.

Access to this register needs to get serialized.

So after several iterations of discussions with the following ideas:
* syscon - device tree should describe HW not drivers to use - 'compatiblity = "brcm,bcm2835-aux-enable", "syscon";' is not acceptable
* regulator - it is not necessarily a regulator or a power gate that is implemented in HW, so it is not valid to use this framework

The recommendation was made to create a new minimal API in soc just for access to this shared enable/disable register.

This patch-series implements:
* the bcm2835-auxiliar device enable/disable api in soc.
* the bcm2835-auxiliar spi device driver

The uart1 device driver (ns16550 based) is not implemented so far but would be using the same API.

Both spi and uart drivers can run with shared interrupts, so there is no need for an interrupt-controller to get implemented.

Martin Sperl (6):
soc: bcm2835: auxiliar devices enable infrastructure
ARM: bcm2835: add DT for the bcm2835 auxiliar devices dt/bindings: bcm2835: add binding documentation for bcm2835-aux
spi: bcm2835: new driver implementing auxiliar spi1/spi2 on the

    bcm2835 soc

ARM: bcm2835: enable building of spi-bcm2835aux driver in default
config
dt/bindings: bcm2835: Add binding documentation for auxiliar spi
devices

 .../bindings/soc/bcm/brcm,bcm2835-aux.txt          |   27 +
 .../bindings/spi/brcm,bcm2835-aux-spi.txt          |   47 ++
 arch/arm/boot/dts/bcm2835.dtsi                     |   37 ++
 arch/arm/configs/bcm2835_defconfig                 |    1 +
 drivers/soc/Kconfig                                |    1 +
 drivers/soc/Makefile                               |    1 +
 drivers/soc/bcm/Kconfig                            |   11 +
 drivers/soc/bcm/Makefile                           |    1 +
 drivers/soc/bcm/bcm2835-aux.c                      |  154 ++++++
 drivers/spi/Kconfig                                |   12 +
 drivers/spi/Makefile                               |    1 +
 drivers/spi/spi-bcm2835aux.c                       |  514 ++++++++++++++++++++
 include/linux/soc/bcm/bcm2835-aux.h                |   23 +
 13 files changed, 830 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-aux.txt
 create mode 100644 Documentation/devicetree/bindings/spi/brcm,bcm2835-aux-spi.txt
 create mode 100644 drivers/soc/bcm/Kconfig
 create mode 100644 drivers/soc/bcm/Makefile
 create mode 100644 drivers/soc/bcm/bcm2835-aux.c
 create mode 100644 drivers/spi/spi-bcm2835aux.c
 create mode 100644 include/linux/soc/bcm/bcm2835-aux.h

--
1.7.10.4

#1 lore raw

PATCH v5 1/6 soc: bcm2835: auxiliar devices enable infrastructure

From: Martin Sperl <[email protected]>

The bcm2835 SOC contains 3 auxiliar devices (spi1, spi2 and uart1) that all are enabled via a shared register.

To serialize access to this shared register this soc-driver is created that implements:
bcm2835aux_enable(struct device *dev, const char *property); bcm2835aux_disable(struct device *dev, const char *property);

Which will read the property from the device tree of the device and enable/disable that specific device as per device tree.

First use of this api will be spi-bcm2835aux.

This driver does not implement an interrupt-controller, so only access to the auxiliar-device-enable register is required.

---
 drivers/soc/Kconfig                 |    1 +
 drivers/soc/Makefile                |    1 +
 drivers/soc/bcm/Kconfig             |   11 +++
 drivers/soc/bcm/Makefile            |    1 +
 drivers/soc/bcm/bcm2835-aux.c       |  154 +++++++++++++++++++++++++++++++++++
 include/linux/soc/bcm/bcm2835-aux.h |   23 ++++++
 6 files changed, 191 insertions(+)
 create mode 100644 drivers/soc/bcm/Kconfig
 create mode 100644 drivers/soc/bcm/Makefile
 create mode 100644 drivers/soc/bcm/bcm2835-aux.c
 create mode 100644 include/linux/soc/bcm/bcm2835-aux.h
drivers/soc/Kconfig +1 -0
index 96ddecb..5506e39 100644
@@ -1,5 +1,6 @@
 menu "SOC (System On Chip) specific Drivers"
 
+source "drivers/soc/bcm/Kconfig"
 source "drivers/soc/mediatek/Kconfig"
 source "drivers/soc/qcom/Kconfig"
 source "drivers/soc/sunxi/Kconfig"
drivers/soc/Makefile +1 -0
index 7dc7c0d..c5744e1 100644
@@ -2,6 +2,7 @@
 # Makefile for the Linux Kernel SOC specific device drivers.
 #
 
+obj-$(CONFIG_ARCH_BCM)		+= bcm/
 obj-$(CONFIG_ARCH_MEDIATEK)	+= mediatek/
 obj-$(CONFIG_ARCH_QCOM)		+= qcom/
 obj-$(CONFIG_ARCH_SUNXI)	+= sunxi/
drivers/soc/bcm/Kconfig new file +11 -0
new file mode 100644
index 0000000..e57e98f
@@ -0,0 +1,11 @@
+#
+# Broadcom SoC drivers
+#
+config SOC_BCM2835_AUX
+	tristate "Broadcom BCM2835 aux"
+	depends on OF
+	depends on ARCH_BCM2835 || COMPILE_TEST
+
+	help
+	  Support to enable/disable the BCM2835 auxiliar
+	  devices spi1, spi2, uart1
drivers/soc/bcm/Makefile new file +1 -0
new file mode 100644
index 0000000..370a872
@@ -0,0 +1 @@
+obj-$(CONFIG_SOC_BCM2835_AUX) += bcm2835-aux.o
drivers/soc/bcm/bcm2835-aux.c new file +154 -0

154 lines not on this page · raw message

include/linux/soc/bcm/bcm2835-aux.h new file +23 -0
new file mode 100644
index 0000000..17a64c6
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2015 Martin Sperl
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef __BCM2835_AUX_H__
+#define __BCM2835_AUX_H__
+
+struct device;
+
+int bcm2835aux_enable(struct device *dev, const char *property);
+int bcm2835aux_disable(struct device *dev, const char *property);
+
+#endif

--
1.7.10.4

#2 lore raw

PATCH v5 2/6 ARM: bcm2835: add DT for the bcm2835 auxiliar devices

In reply to [email protected]

From: Martin Sperl <[email protected]>

Add device tree definitions for auxiliar bcm2835 devices:
* spi1
* spi2
* uart1

This also include a device to get used by the relevant device-drivers (via a shared register) to enable/disable the HW-block.

The aux-interrupt-register (0x7e21500) is intentionally left out of scope, so that in the future it is still possible to implement a separate interrupt-driver - if deemed necessary.

The spi (and also uart) drivers are able to use shared interrupts, so there is no real need for an interrupt driver.

---
 arch/arm/boot/dts/bcm2835.dtsi |   37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
arch/arm/boot/dts/bcm2835.dtsi +37 -0
index 301c73f..4e6fc61 100644
@@ -158,6 +158,43 @@
 		arm-pmu {
 			compatible = "arm,arm1176-pmu";
 		};
+
+		aux_enable: aux_enable at 0x7e215004 {
+			compatible = "brcm,bcm2835-aux";
+			reg = <0x7e215004 0x04>;
+			#address-cells = <1>;
+			#size-cells = <0>;
+		};
+
+		uart1: uart at 7e215040 {
+			compatible = "brcm,bcm2835-aux-uart";
+			reg = <0x7e215040 0x40>;
+			interrupts = <1 29>;
+			brcm,aux-enable = <&aux_enable 1>;
+			status = "disabled";
+		};
+
+		spi1: spi at 7e215080 {
+			compatible = "brcm,bcm2835-aux-spi";
+			reg = <0x7e215080 0x40>;
+			brcm,aux-enable = <&aux_enable 2>;
+			interrupts = <1 29>;
+			clocks = <&clk_spi>;
+			#address-cells = <1>;
+			#size-cells = <0>;
+			status = "disabled";
+		};
+
+		spi2: spi at 7e2150c0 {
+			compatible = "brcm,bcm2835-aux-spi";
+			reg = <0x7e2150c0 0x40>;
+			brcm,aux-enable = <&aux_enable 4>;
+			interrupts = <1 29>;
+			clocks = <&clk_spi>;
+			#address-cells = <1>;
+			#size-cells = <0>;
+			status = "disabled";
+		};
 	};
 
 	clocks {

--
1.7.10.4

#3 lore raw

PATCH v5 3/6 dt/bindings: bcm2835: add binding documentation for bcm2835-aux

In reply to [email protected]

From: Martin Sperl <[email protected]>

add binding documentation

---
 .../bindings/soc/bcm/brcm,bcm2835-aux.txt          |   27 ++++++++++++++++++++
 1 file changed, 27 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-aux.txt
Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-aux.txt new file +27 -0
new file mode 100644
index 0000000..8b79cf3
@@ -0,0 +1,27 @@
+Broadcom BCM2835 auxiliar device enable register
+
+the BCM2835 contains 3 auxiliar devices (spi1/spi2/uart1)
+which need to get enabled via a shared register.
+
+Required properties:
+- compatible: Should be "brcm,bcm2835-aux".
+- reg: Should contain register location and length for the
+       enable register
+
+Example:
+
+aux_enable: aux_enable at 0x7e215004 {
+	compatible = "bcrm,bcm2835-aux";
+	reg = <0x7e215004 0x04>;
+};
+
+Typically used in the respective auxiliar device descriptions
+like this:
+
+uart1: uart at 7e215040 {
+	...
+	brcm,aux-enable = <&aux_enable 1>;
+	...
+};
+
+The name of the property can be device/driver specific.

--
1.7.10.4

#4 lore raw

PATCH v5 4/6 spi: bcm2835: new driver implementing auxiliar spi1/spi2 on the bcm2835 soc

In reply to [email protected]

From: Martin Sperl <[email protected]>

Implements spi master driver for the 2 auxiliar spi devices supported by the bcm2835 SOC.

The driver does not implement native chip-selects but uses framework provided aribtrary GPIO-chip-selects.

Requires soc-bcm2835-aux enable api to enable/disable HW blocks.

---
 drivers/spi/Kconfig          |   12 +
 drivers/spi/Makefile         |    1 +
 drivers/spi/spi-bcm2835aux.c |  514 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 527 insertions(+)
 create mode 100644 drivers/spi/spi-bcm2835aux.c

Changelog:
v4->v5: added error-handling and deferred probing support
moved change to default-config to a separate patch fixed Kconfig to add the correct dependency

drivers/spi/Kconfig +12 -0
index 4887f31..25242cc 100644
@@ -88,6 +88,18 @@ config SPI_BCM2835
 	  is for the regular SPI controller. Slave mode operation is not also
 	  not supported.
 
+config SPI_BCM2835AUX
+	tristate "BCM2835 SPI auxiliar controller"
+	depends on ARCH_BCM2835 || COMPILE_TEST
+	depends on GPIOLIB
+	select SOC_BCM2835_AUX
+	help
+	  This selects a driver for the Broadcom BCM2835 SPI aux master.
+
+	  The BCM2835 contains two types of SPI master controller; the
+	  "universal SPI master", and the regular SPI controller.
+	  This driver is for the universal/auxiliar SPI controller.
+
 config SPI_BFIN5XX
 	tristate "SPI controller driver for ADI Blackfin5xx"
 	depends on BLACKFIN && !BF60x
drivers/spi/Makefile +1 -0
index 6a7f6f9..31fb7fb 100644
@@ -15,6 +15,7 @@ obj-$(CONFIG_SPI_ATMEL)			+= spi-atmel.o
 obj-$(CONFIG_SPI_ATH79)			+= spi-ath79.o
 obj-$(CONFIG_SPI_AU1550)		+= spi-au1550.o
 obj-$(CONFIG_SPI_BCM2835)		+= spi-bcm2835.o
+obj-$(CONFIG_SPI_BCM2835AUX)		+= spi-bcm2835aux.o
 obj-$(CONFIG_SPI_BCM53XX)		+= spi-bcm53xx.o
 obj-$(CONFIG_SPI_BCM63XX)		+= spi-bcm63xx.o
 obj-$(CONFIG_SPI_BCM63XX_HSSPI)		+= spi-bcm63xx-hsspi.o
drivers/spi/spi-bcm2835aux.c new file +514 -0

514 lines not on this page · raw message

--
1.7.10.4

#5 lore raw

Re: [PATCH v5 4/6] spi: bcm2835: new driver implementing auxiliar spi1/spi2 on the bcm2835 soc

Quoted 18 lines · kernel at martin.sperl.org

From: Martin Sperl <[email protected]>

Implements spi master driver for the 2 auxiliar spi devices supported by the bcm2835 SOC.

The driver does not implement native chip-selects but uses framework provided aribtrary GPIO-chip-selects.

Requires soc-bcm2835-aux enable api to enable/disable HW blocks.

---
 drivers/spi/Kconfig          |   12 +
 drivers/spi/Makefile         |    1 +
 drivers/spi/spi-bcm2835aux.c |  514 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 527 insertions(+)
 create mode 100644 drivers/spi/spi-bcm2835aux.c
Quoted 4 lines

Changelog:
v4->v5: added error-handling and deferred probing support
moved change to default-config to a separate patch fixed Kconfig to add the correct dependency

Review comments as a diff, so you can git-am and squash them in if you like. If you take them all, you can add "Acked-by: Eric Anholt <[email protected]>".

I didn't know anything about SPI before tonight, but I've looked through what you did and it looks solid when compared to the hardware docs I've got. The only functional comment I had that's not in my diff is that you could probably reduce the transfer overhead by knowing that there are 4 dwords in the transfer and receive FIFOs, so I think you could write more before checking if you had to stop.

Quoted 1 line

From e082c3b5ea32d3eb1a40b7f9b5a822ba307cf886 Mon Sep 17 00:00:00 2001

From: Eric Anholt <[email protected]>
Date: Tue, 8 Sep 2015 17:51:08 -0700
Subject: [PATCH] spi: Changes for Martin's aux spi driver.

The intention is for these to be review fixes squashed into his commit of the driver.

- Reset has to happen before the clock gate is disabled, since register writes wouldn't take effect.

- Typo fixes.

- Dropped unnecessary regs/defines.

- Dropped custom clock enable/disable, assuming we use the aux clock driver instead.

---
 drivers/spi/Kconfig          |  5 ++---
 drivers/spi/spi-bcm2835aux.c | 45 ++++++--------------------------------------
 2 files changed, 8 insertions(+), 42 deletions(-)
drivers/spi/Kconfig +2 -3
index cdb3dba..20854d4 100644
@@ -89,16 +89,15 @@ config SPI_BCM2835
 	  not supported.
 
 config SPI_BCM2835AUX
-	tristate "BCM2835 SPI auxiliar controller"
+	tristate "BCM2835 SPI auxiliary controller"
 	depends on ARCH_BCM2835 || COMPILE_TEST
 	depends on GPIOLIB
-	select SOC_BCM2835_AUX
 	help
 	  This selects a driver for the Broadcom BCM2835 SPI aux master.
 
 	  The BCM2835 contains two types of SPI master controller; the
 	  "universal SPI master", and the regular SPI controller.
-	  This driver is for the universal/auxiliar SPI controller.
+	  This driver is for the universal/auxiliary SPI controller.
 
 config SPI_BFIN5XX
 	tristate "SPI controller driver for ADI Blackfin5xx"
drivers/spi/spi-bcm2835aux.c +6 -39

100 lines not on this page · raw message

Signature · 8 lines
2.1.4
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 818 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150908/b100af71/attachment.sig>
#6 lore raw

PATCH v5 5/6 ARM: bcm2835: enable building of spi-bcm2835aux driver in default config

In reply to [email protected]

From: Martin Sperl <[email protected]>

Added spi-bcm2835aux to default config

---
 arch/arm/configs/bcm2835_defconfig |    1 +
 1 file changed, 1 insertion(+)
arch/arm/configs/bcm2835_defconfig +1 -0
index 31cb073..a205c8b 100644
@@ -75,6 +75,7 @@ CONFIG_I2C_CHARDEV=y
 CONFIG_I2C_BCM2835=y
 CONFIG_SPI=y
 CONFIG_SPI_BCM2835=y
+CONFIG_SPI_BCM2835AUX=y
 CONFIG_GPIO_SYSFS=y
 # CONFIG_HWMON is not set
 CONFIG_FB=y

--
1.7.10.4

#7 lore raw

PATCH v5 6/6 dt/bindings: bcm2835: Add binding documentation for auxiliar spi devices

In reply to [email protected]

From: Martin Sperl <[email protected]>

add binding documentation

---
 .../bindings/spi/brcm,bcm2835-aux-spi.txt          |   47 ++++++++++++++++++++
 1 file changed, 47 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/spi/brcm,bcm2835-aux-spi.txt

Changelog:
v4->v5: fixed wording for reg
removed reference to syscon removed documentation on typical GPIO config

Documentation/devicetree/bindings/spi/brcm,bcm2835-aux-spi.txt new file +47 -0
new file mode 100644
index 0000000..3ade499
@@ -0,0 +1,47 @@
+Broadcom BCM2835 auxiliar SPI1/2 controller
+
+The BCM2835 contains two forms of SPI master controller, one known simply as
+SPI0, and the other known as the "Universal SPI Master"; part of the
+auxiliary block. This binding applies to the SPI1/2 controller.
+
+Required properties:
+- compatible: Should be "brcm,bcm2835-aux-spi".
+- reg: Should contain register location and length for the spi block
+- interrupts: Should contain shared interrupt of the aux block
+- clocks: The clock feeding the SPI controller.
+- cs-gpios: the cs-gpios (native cs is NOT supported)
+	    see also spi-bus.txt
+- bcrm,aux-enable: the bcrm,bcm2835-aux-enable config entry to handle
+		  enabling/disabling of the spi1/spi2/uart1 HW block
+		  second "argument" is the mask to apply to the
+		  enable register
+
+Example:
+
+spi1 at 7e215080 {
+	compatible = "brcm,bcm2835-aux-spi";
+	reg = <0x7e215080 0x40>;
+	interrupts = <1 29>;
+	clocks = <&clk_spi>;
+	#address-cells = <1>;
+	#size-cells = <0>;
+	cs-gpios = <&gpio 18>, <&gpio 17>, <&gpio 16>;
+	bcrm,aux-enable = <&aux_enable 2>;
+};
+
+spi2 at 7e2150c0 {
+	compatible = "brcm,bcm2835-aux-spi";
+	reg = <0x7e2150c0 0x40>;
+	interrupts = <1 29>;
+	clocks = <&clk_spi>;
+	#address-cells = <1>;
+	#size-cells = <0>;
+	cs-gpios = <&gpio 43>, <&gpio 44>, <&gpio 45>;
+	bcrm,aux-enable = <&aux_enable 4>;
+};
+
+/* the necessary bcm2835 aux-enable referenced above */
+aux_enable: aux_enable at 0x7e215004 {
+	compatible = "bcrm,bcm2835-aux";
+	reg = <0x7e215004 0x04>;
+};

--
1.7.10.4

#8 lore raw
In reply to [email protected]
Quoted 27 lines · kernel at martin.sperl.org

From: Martin Sperl <[email protected]>

The BCM2835 contains 3 auxiliar devices:
* spi1
* spi2
* uart1

All of those 3 devices are enabled/disabled via a shared register, which is set by default to be disabled.

Access to this register needs to get serialized.

So after several iterations of discussions with the following ideas:
* syscon - device tree should describe HW not drivers to use - 'compatiblity = "brcm,bcm2835-aux-enable", "syscon";' is not acceptable
* regulator - it is not necessarily a regulator or a power gate that is implemented in HW, so it is not valid to use this framework

The recommendation was made to create a new minimal API in soc just for access to this shared enable/disable register.

This patch-series implements:
* the bcm2835-auxiliar device enable/disable api in soc.
* the bcm2835-auxiliar spi device driver

Quoted 5 lines

The uart1 device driver (ns16550 based) is not implemented so far but would be using the same API.

Both spi and uart drivers can run with shared interrupts, so there is no need for an interrupt-controller to get implemented.

I finally had a chance to sit down and look at what the hardware's doing with the enable bit (also, I've read a whole lot more of the hardware now, so I'm a lot faster at answering questions like this). The enable bits are a clock gate off of the VPU clock.

I knocked together the enable bits as a clock gate driver, since I'd
just written very similar code for the audio domain clock driver (and I
assume you are grumpy about how much time you've spent on this one
stupid register). It's up at
https://github.com/anholt/linux/tree/bcm2835-clock-aux and I can submit
it if you like the result. I've compile tested it only, but I'm hoping
you could just drop your aux SPI driver on top of it and have things
work.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 818 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150908/1bb7fdb0/attachment-0001.sig>

#9 lore raw

Hi,

Quoted 4 lines · Eric Anholt

I finally had a chance to sit down and look at what the hardware's doing with the enable bit (also, I've read a whole lot more of the hardware now, so I'm a lot faster at answering questions like this). The enable bits are a clock gate off of the VPU clock.

Are any hardware documents about such things available (in public)?

Quoted 8 lines

I knocked together the enable bits as a clock gate driver, since I'd just written very similar code for the audio domain clock driver (and I assume you are grumpy about how much time you've spent on this one stupid register). It's up at
https://github.com/anholt/linux/tree/bcm2835-clock-aux and I can submit it if you like the result. I've compile tested it only, but I'm hoping you could just drop your aux SPI driver on top of it and have things work.

IMHO line 45 (https://github.com/anholt/linux/commit/facb4ba917a1b9f6c2ee0cea7d529acf55f584dd#diff-1b6f753c132811b3f6d70f5b31866950R45) should be like this

Quoted 1 line

onecell->clks = kzalloc(sizeof(*onecell->clks) * BCM2835_AUX_CLOCK_COUNT, GFP_KERNEL);

or you will only allocate a single struct clk*.

Best regards,
Alexander

#10 lore raw
Quoted 8 lines · Alexander Stein

Hi,

Quoted 4 lines · Eric Anholt

I finally had a chance to sit down and look at what the hardware's doing with the enable bit (also, I've read a whole lot more of the hardware now, so I'm a lot faster at answering questions like this). The enable bits are a clock gate off of the VPU clock.

Are any hardware documents about such things available (in public)?

Nope, I just went through the HDL to see how things were routed.

Quoted 9 lines
Quoted 8 lines

I knocked together the enable bits as a clock gate driver, since I'd just written very similar code for the audio domain clock driver (and I assume you are grumpy about how much time you've spent on this one stupid register). It's up at
https://github.com/anholt/linux/tree/bcm2835-clock-aux and I can submit it if you like the result. I've compile tested it only, but I'm hoping you could just drop your aux SPI driver on top of it and have things work.

Quoted 3 lines

IMHO line 45 (https://github.com/anholt/linux/commit/facb4ba917a1b9f6c2ee0cea7d529acf55f584dd#diff-1b6f753c132811b3f6d70f5b31866950R45) should be like this

Quoted 1 line

onecell->clks = kzalloc(sizeof(*onecell->clks) * BCM2835_AUX_CLOCK_COUNT, GFP_KERNEL);

or you will only allocate a single struct clk*.

Thanks, that was a bug in my other clock driver, too!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 818 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150909/4f6ac866/attachment.sig>

#11 lore raw
In reply to Eric Anholt

Den 09.09.2015 03:48, skrev Eric Anholt:

Quoted 39 lines
Quoted 27 lines · kernel at martin.sperl.org

From: Martin Sperl <[email protected]>

The BCM2835 contains 3 auxiliar devices:
* spi1
* spi2
* uart1

All of those 3 devices are enabled/disabled via a shared register, which is set by default to be disabled.

Access to this register needs to get serialized.

So after several iterations of discussions with the following ideas:
* syscon - device tree should describe HW not drivers to use - 'compatiblity = "brcm,bcm2835-aux-enable", "syscon";' is not acceptable
* regulator - it is not necessarily a regulator or a power gate that is implemented in HW, so it is not valid to use this framework

The recommendation was made to create a new minimal API in soc just for access to this shared enable/disable register.

This patch-series implements:
* the bcm2835-auxiliar device enable/disable api in soc.
* the bcm2835-auxiliar spi device driver

Quoted 5 lines

The uart1 device driver (ns16550 based) is not implemented so far but would be using the same API.

Both spi and uart drivers can run with shared interrupts, so there is no need for an interrupt-controller to get implemented.

I finally had a chance to sit down and look at what the hardware's doing with the enable bit (also, I've read a whole lot more of the hardware now, so I'm a lot faster at answering questions like this). The enable bits are a clock gate off of the VPU clock.

Quoted 9 lines

I knocked together the enable bits as a clock gate driver, since I'd just written very similar code for the audio domain clock driver (and I assume you are grumpy about how much time you've spent on this one stupid register). It's up at
https://github.com/anholt/linux/tree/bcm2835-clock-aux and I can submit it if you like the result. I've compile tested it only, but I'm hoping you could just drop your aux SPI driver on top of it and have things work.

This looks interesting.
But there's a challenge with the uart1 and the 8250 driver.

Phil Elwell has this to say:
This means that that UART1 isn't an exact clone of a 8250 UART. In a particular, the clock divisor is calculated differently. A standard 8250 derives the baud rate as clock/(divisor16), whereas the BCM2835 mini UART uses clock/(divisor8). This means that if you want to use the standard driver then you need to lie about the clock frequency, providing a value is twice the real value, in order for a suitable divisor to be calculated.

Ref: https://github.com/raspberrypi/linux/pull/1008#issuecomment-139234607

So either we need a new uart1 driver or a doubled clock freq. somehow.

Noralf.

#12 lore raw
Quoted 15 lines · Noralf Tr?nnes

This looks interesting.
But there's a challenge with the uart1 and the 8250 driver.

Phil Elwell has this to say:
This means that that UART1 isn't an exact clone of a 8250 UART. In a particular, the clock divisor is calculated differently. A standard 8250 derives the baud rate as clock/(divisor16), whereas the BCM2835 mini UART uses clock/(divisor8). This means that if you want to use the standard driver then you need to lie about the clock frequency, providing a value is twice the real value, in order for a suitable divisor to be calculated.

Quoted 3 lines

Ref: https://github.com/raspberrypi/linux/pull/1008#issuecomment-139234607

So either we need a new uart1 driver or a doubled clock freq. somehow.

Found out the same thing and communicated it to Eric - not knowing about the different divider?

Martin

#13 lore raw

Noralf pointed me at fixed-factor-clock, and that works in our (downstream) environment:

    soc: soc {
        ...
        uart1: uart@7e215040 {
            compatible = "brcm,bcm2835-aux-uart", "ns16550";
            reg = <0x7e215040 0x40>;
            interrupts = <1 29>;
            clocks = <&clk_uart1>;
            reg-shift = <2>;
            no-loopback-test;
            status = "disabled";
            };
    };

    clocks: clocks {
        ...
        clk_core: clock@2 {
            compatible = "fixed-clock";
            reg = <2>;
            #clock-cells = <0>;
            clock-output-names = "core";
            clock-frequency = <250000000>;
        };
        ...
        clk_uart1: clock@6 {
            compatible = "fixed-factor-clock";
            clocks = <&clk_core>;
            #clock-cells = <0>;
            clock-div = <1>;
            clock-mult = <2>;
        };
    };

Phil

Quoted 21 lines · Martin Sperl
Quoted 14 lines · Noralf Tr�nnes

This looks interesting.
But there's a challenge with the uart1 and the 8250 driver.

Phil Elwell has this to say:
This means that that UART1 isn't an exact clone of a 8250 UART. In a particular, the clock divisor is calculated differently. A standard 8250 derives the baud rate as clock/(divisor16), whereas the BCM2835 mini UART uses clock/(divisor8). This means that if you want to use the standard driver then you need to lie about the clock frequency, providing a value is twice the real value, in order for a suitable divisor to be calculated.

Quoted 3 lines

Ref: https://github.com/raspberrypi/linux/pull/1008#issuecomment-139234607

So either we need a new uart1 driver or a doubled clock freq. somehow.

Found out the same thing and communicated it to Eric - not knowing about the different divider�

Martin

#14 lore raw
In reply to Martin Sperl

[ Sending again in plain text ]
Noralf pointed me at fixed-factor-clock, and that works in our (downstream) environment:

    soc: soc {
        ...
        uart1: uart at 7e215040 {
            compatible = "brcm,bcm2835-aux-uart", "ns16550";
            reg = <0x7e215040 0x40>;
            interrupts = <1 29>;
            clocks = <&clk_uart1>;
            reg-shift = <2>;
            no-loopback-test;
            status = "disabled";
            };
    };

    clocks: clocks {
        ...
        clk_core: clock at 2 {
            compatible = "fixed-clock";
            reg = <2>;
            #clock-cells = <0>;
            clock-output-names = "core";
            clock-frequency = <250000000>;
        };
        ...
        clk_uart1: clock at 6 {
            compatible = "fixed-factor-clock";
            clocks = <&clk_core>;
            #clock-cells = <0>;
            clock-div = <1>;
            clock-mult = <2>;
        };
    };

Phil

Quoted 21 lines · Martin Sperl
Quoted 14 lines · Noralf Tr?nnes

This looks interesting.
But there's a challenge with the uart1 and the 8250 driver.

Phil Elwell has this to say:
This means that that UART1 isn't an exact clone of a 8250 UART. In a particular, the clock divisor is calculated differently. A standard 8250 derives the baud rate as clock/(divisor16), whereas the BCM2835 mini UART uses clock/(divisor8). This means that if you want to use the standard driver then you need to lie about the clock frequency, providing a value is twice the real value, in order for a suitable divisor to be calculated.

Quoted 3 lines

Ref: https://github.com/raspberrypi/linux/pull/1008#issuecomment-139234607

So either we need a new uart1 driver or a doubled clock freq. somehow.

Found out the same thing and communicated it to Eric - not knowing about the different divider?

Martin

Quoted 21 lines · Martin Sperl
Quoted 14 lines · Noralf Tr?nnes

This looks interesting.
But there's a challenge with the uart1 and the 8250 driver.

Phil Elwell has this to say:
This means that that UART1 isn't an exact clone of a 8250 UART. In a particular, the clock divisor is calculated differently. A standard 8250 derives the baud rate as clock/(divisor16), whereas the BCM2835 mini UART uses clock/(divisor8). This means that if you want to use the standard driver then you need to lie about the clock frequency, providing a value is twice the real value, in order for a suitable divisor to be calculated.

Quoted 3 lines

Ref: https://github.com/raspberrypi/linux/pull/1008#issuecomment-139234607

So either we need a new uart1 driver or a doubled clock freq. somehow.

Found out the same thing and communicated it to Eric - not knowing about the different divider?

Martin