Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1209609 > unrolled thread
| Started by | Chen-Yu Tsai <wens@csie.org> |
|---|---|
| First post | 2015-08-19 06:30 +0200 |
| Last post | 2015-08-20 19:10 +0200 |
| Articles | 12 — 4 participants |
Back to article view | Back to linux.kernel
[PATCH v3 0/8] ARM: sunxi: Add Reduced Serial Bus support Chen-Yu Tsai <wens@csie.org> - 2015-08-19 06:30 +0200
[PATCH v3 6/8] ARM: dts: sun8i: Add Reduced Serial Bus controller device node to A23/A33 dtsi Chen-Yu Tsai <wens@csie.org> - 2015-08-19 06:30 +0200
[PATCH v3 3/8] rsb: Linux driver framework for Reduced Serial Bus (RSB) Chen-Yu Tsai <wens@csie.org> - 2015-08-19 06:30 +0200
Re: [PATCH v3 3/8] rsb: Linux driver framework for Reduced Serial Bus (RSB) Mark Brown <broonie@kernel.org> - 2015-08-20 19:10 +0200
[PATCH v3 1/8] rsb: Add generic Reduced Serial Bus (RSB) controller binding documentation Chen-Yu Tsai <wens@csie.org> - 2015-08-19 06:30 +0200
Re: [PATCH v3 1/8] rsb: Add generic Reduced Serial Bus (RSB) controller binding documentation Maxime Ripard <maxime.ripard@free-electrons.com> - 2015-08-20 17:10 +0200
Re: [PATCH v3 1/8] rsb: Add generic Reduced Serial Bus (RSB) controller binding documentation Chen-Yu Tsai <wens@csie.org> - 2015-08-20 18:00 +0200
Re: [PATCH v3 1/8] rsb: Add generic Reduced Serial Bus (RSB) controller binding documentation Maxime Ripard <maxime.ripard@free-electrons.com> - 2015-08-20 23:30 +0200
Re: [PATCH v3 1/8] rsb: Add generic Reduced Serial Bus (RSB) controller binding documentation Rob Herring <robherring2@gmail.com> - 2015-08-24 00:50 +0200
Re: [PATCH v3 0/8] ARM: sunxi: Add Reduced Serial Bus support Mark Brown <broonie@kernel.org> - 2015-08-19 18:40 +0200
Re: [PATCH v3 0/8] ARM: sunxi: Add Reduced Serial Bus support Chen-Yu Tsai <wens@csie.org> - 2015-08-20 04:10 +0200
Re: [PATCH v3 0/8] ARM: sunxi: Add Reduced Serial Bus support Mark Brown <broonie@kernel.org> - 2015-08-20 19:10 +0200
| From | Chen-Yu Tsai <wens@csie.org> |
|---|---|
| Date | 2015-08-19 06:30 +0200 |
| Subject | [PATCH v3 0/8] ARM: sunxi: Add Reduced Serial Bus support |
| Message-ID | <pZ3aG-3oT-3@gated-at.bofh.it> |
Hi everyone,
This is my third attempt at adding support for Allwinner's Reduced
Serial Bus (RSB), which is used to communicate with PMICs and other
peripherals on their newer SoCs, such as the A23/A33/A80.
RSB is a simplified two wire interface using push-pull outputs,
supporting multiple slaves, address and data parity checks, and
clock speeds up to 20 MHz. The bus only supports simple register
read/writes, with possible register sizes of 8/16/32 bits. Access
sizes not matching the slave device register sizes result in NACKs
or errors. 32 bit registers in devices have yet to be seen.
Previous attempts to add support through the I2C subsystem have
been rejected, as the bus line protocol is too different to even
consider. In this version, RSB is implemented as a new bus type,
much like SPMI.
Even though there will almost certainly be only one RSB driver,
it's still split into the bus core framework and vendor specific
driver, like other subsystems. Theoretically someone could
implement a bit-banging driver for it.
Patches 1 & 2 add the DT bindings for common RSB properties and
the controller.
Patches 3 & 4 add the RSB framework core and sunxi driver.
Patch 5 (based on regmap/for-next) adds an RSB regmap driver.
Patch 6 adds the RSB nodes for A23/A33 dtsi.
Patch 7 & 8 enable the RSB controller on the boards I have.
Still to come are axp20x driver support for the RSB based AXP223.
The complete series can be found at:
https://github.com/wens/linux/tree/sunxi-rsb-v3
Since this is a new subsystem, I'm not sure who should pick up
the first 4 patches, or whether they are even in the right place.
Any suggestions?
Regards,
ChenYu
Chen-Yu Tsai (8):
rsb: Add generic Reduced Serial Bus (RSB) controller binding
documentation
rsb: sunxi: Add Allwinner Reduced Serial Bus (RSB) controller bindings
rsb: Linux driver framework for Reduced Serial Bus (RSB)
rsb: sunxi: Add driver for Allwinner Reduced Serial Bus controller
regmap: rsb: Add support for Reduced Serial Bus (RSB) based regmaps
ARM: dts: sun8i: Add Reduced Serial Bus controller device node to
A23/A33 dtsi
ARM: dts: sun8i: ippo-q8h-v5: Enable Reduced Serial Bus controller
ARM: dts: sun8i: sinlinx-sina33: Enable Reduced Serial Bus controller
.../devicetree/bindings/rsb/rsb-sunxi.txt | 34 ++
Documentation/devicetree/bindings/rsb/rsb.txt | 50 ++
arch/arm/boot/dts/sun8i-a23-a33.dtsi | 21 +
arch/arm/boot/dts/sun8i-a23-ippo-q8h-v5.dts | 4 +
arch/arm/boot/dts/sun8i-a33-sinlinx-sina33.dts | 4 +
drivers/Kconfig | 2 +
drivers/Makefile | 1 +
drivers/base/regmap/Kconfig | 6 +-
drivers/base/regmap/Makefile | 1 +
drivers/base/regmap/regmap-rsb.c | 121 +++++
drivers/rsb/Kconfig | 26 ++
drivers/rsb/Makefile | 6 +
drivers/rsb/rsb-core.c | 511 +++++++++++++++++++++
drivers/rsb/rsb-sunxi.c | 441 ++++++++++++++++++
include/linux/regmap.h | 36 ++
include/linux/rsb.h | 144 ++++++
16 files changed, 1407 insertions(+), 1 deletion(-)
create mode 100644 Documentation/devicetree/bindings/rsb/rsb-sunxi.txt
create mode 100644 Documentation/devicetree/bindings/rsb/rsb.txt
create mode 100644 drivers/base/regmap/regmap-rsb.c
create mode 100644 drivers/rsb/Kconfig
create mode 100644 drivers/rsb/Makefile
create mode 100644 drivers/rsb/rsb-core.c
create mode 100644 drivers/rsb/rsb-sunxi.c
create mode 100644 include/linux/rsb.h
--
2.5.0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Chen-Yu Tsai <wens@csie.org> |
|---|---|
| Date | 2015-08-19 06:30 +0200 |
| Subject | [PATCH v3 6/8] ARM: dts: sun8i: Add Reduced Serial Bus controller device node to A23/A33 dtsi |
| Message-ID | <pZ3aG-3oT-21@gated-at.bofh.it> |
| In reply to | #1209609 |
This patch adds a device node for the Reduced Serial Bus (RSB)
controller and the defacto pinmux setting to the A23/A33 dtsi.
Since there is only one possible pinmux setting for RSB, just
set it in the dtsi.
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
arch/arm/boot/dts/sun8i-a23-a33.dtsi | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/arch/arm/boot/dts/sun8i-a23-a33.dtsi b/arch/arm/boot/dts/sun8i-a23-a33.dtsi
index 27a925ec17d2..db3671382cb2 100644
--- a/arch/arm/boot/dts/sun8i-a23-a33.dtsi
+++ b/arch/arm/boot/dts/sun8i-a23-a33.dtsi
@@ -661,6 +661,13 @@
#size-cells = <0>;
#gpio-cells = <3>;
+ r_rsb_pins: r_rsb {
+ allwinner,pins = "PL0", "PL1";
+ allwinner,function = "s_rsb";
+ allwinner,drive = <SUN4I_PINCTRL_20_MA>;
+ allwinner,pull = <SUN4I_PINCTRL_PULL_UP>;
+ };
+
r_uart_pins_a: r_uart@0 {
allwinner,pins = "PL2", "PL3";
allwinner,function = "s_uart";
@@ -668,5 +675,19 @@
allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
};
};
+
+ r_rsb: i2c@01f03400 {
+ compatible = "allwinner,sun8i-a23-rsb";
+ reg = <0x01f03400 0x400>;
+ interrupts = <GIC_SPI 39 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&apb0_gates 3>;
+ clock-frequency = <3000000>;
+ resets = <&apb0_rst 3>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&r_rsb_pins>;
+ status = "disabled";
+ #address-cells = <2>;
+ #size-cells = <0>;
+ };
};
};
--
2.5.0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Chen-Yu Tsai <wens@csie.org> |
|---|---|
| Date | 2015-08-19 06:30 +0200 |
| Subject | [PATCH v3 3/8] rsb: Linux driver framework for Reduced Serial Bus (RSB) |
| Message-ID | <pZ3aG-3oT-5@gated-at.bofh.it> |
| In reply to | #1209609 |
Reduced Serial Bus (RSB) is an Allwinner proprietery interface
used to communicate with PMICs and other peripheral ICs.
RSB is a two-wire push-pull serial bus that supports 1 master
device and up to 15 active slave devices.
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
drivers/Kconfig | 2 +
drivers/Makefile | 1 +
drivers/rsb/Kconfig | 11 ++
drivers/rsb/Makefile | 4 +
drivers/rsb/rsb-core.c | 511 +++++++++++++++++++++++++++++++++++++++++++++++++
include/linux/rsb.h | 144 ++++++++++++++
6 files changed, 673 insertions(+)
create mode 100644 drivers/rsb/Kconfig
create mode 100644 drivers/rsb/Makefile
create mode 100644 drivers/rsb/rsb-core.c
create mode 100644 include/linux/rsb.h
diff --git a/drivers/Kconfig b/drivers/Kconfig
index 6e973b8e3a3b..4ada2d3eb832 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -54,6 +54,8 @@ source "drivers/spi/Kconfig"
source "drivers/spmi/Kconfig"
+source "drivers/rsb/Kconfig"
+
source "drivers/hsi/Kconfig"
source "drivers/pps/Kconfig"
diff --git a/drivers/Makefile b/drivers/Makefile
index e4b260ecec15..75e0fc8fe28c 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -75,6 +75,7 @@ obj-$(CONFIG_TARGET_CORE) += target/
obj-$(CONFIG_MTD) += mtd/
obj-$(CONFIG_SPI) += spi/
obj-$(CONFIG_SPMI) += spmi/
+obj-$(CONFIG_RSB) += rsb/
obj-y += hsi/
obj-y += net/
obj-$(CONFIG_ATM) += atm/
diff --git a/drivers/rsb/Kconfig b/drivers/rsb/Kconfig
new file mode 100644
index 000000000000..6642e1db6d98
--- /dev/null
+++ b/drivers/rsb/Kconfig
@@ -0,0 +1,11 @@
+#
+# RSB driver configuration
+#
+menuconfig RSB
+ tristate "RSB support"
+ help
+ RSB (Reduced Serial Bus) is a two-wire serial interface between
+ baseband and application processors and Power Management
+ Integrated Circuits (PMIC) or other peripherals.
+
+ These are commonly seen on newer Allwinner SoCs and X-Powers ICs.
diff --git a/drivers/rsb/Makefile b/drivers/rsb/Makefile
new file mode 100644
index 000000000000..6fe56526fbf3
--- /dev/null
+++ b/drivers/rsb/Makefile
@@ -0,0 +1,4 @@
+#
+# Makefile for kernel RSB framework.
+#
+obj-$(CONFIG_RSB) += rsb-core.o
diff --git a/drivers/rsb/rsb-core.c b/drivers/rsb/rsb-core.c
new file mode 100644
index 000000000000..6682d827aebb
--- /dev/null
+++ b/drivers/rsb/rsb-core.c
@@ -0,0 +1,511 @@
+/*
+ * Copyright (c) 2015, Chen-Yu Tsai
+ *
+ * Chen-Yu Tsai <wens@csie.org>
+ *
+ * Allwinner Reduced Serial Bus (RSB) driver
+ *
+ * based on spmi/spmi.c
+ *
+ * Copyright (c) 2012-2015, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/clk/clk-conf.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/idr.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/of_irq.h>
+#include <linux/platform_device.h>
+#include <linux/rsb.h>
+#include <linux/slab.h>
+
+static DEFINE_IDA(ctrl_ida);
+
+static void rsb_dev_release(struct device *dev)
+{
+ struct rsb_device *rdev = to_rsb_device(dev);
+
+ kfree(rdev);
+}
+
+static const struct device_type rsb_dev_type = {
+ .release = rsb_dev_release,
+};
+
+static void rsb_ctrl_release(struct device *dev)
+{
+ struct rsb_controller *ctrl = to_rsb_controller(dev);
+
+ ida_simple_remove(&ctrl_ida, ctrl->nr);
+ kfree(ctrl);
+}
+
+static const struct device_type rsb_ctrl_type = {
+ .release = rsb_ctrl_release,
+};
+
+static int rsb_device_match(struct device *dev, struct device_driver *drv)
+{
+ if (of_driver_match_device(dev, drv))
+ return 1;
+
+ return strcmp(dev_name(dev), drv->name) == 0;
+}
+
+static inline int rsb_init_cmd(struct rsb_controller *ctrl)
+{
+ int ret;
+
+ if (!ctrl || !ctrl->init_cmd || ctrl->dev.type != &rsb_ctrl_type)
+ return -EINVAL;
+
+ mutex_lock(&ctrl->lock);
+ ret = ctrl->init_cmd(ctrl);
+ mutex_unlock(&ctrl->lock);
+
+ return ret;
+}
+
+static inline int rsb_rtsaddr_cmd(struct rsb_controller *ctrl, u16 hwaddr,
+ u8 rtaddr)
+{
+ int ret;
+
+ if (!ctrl || !ctrl->rtsaddr_cmd || ctrl->dev.type != &rsb_ctrl_type)
+ return -EINVAL;
+
+ mutex_lock(&ctrl->lock);
+ ret = ctrl->rtsaddr_cmd(ctrl, hwaddr, rtaddr);
+ mutex_unlock(&ctrl->lock);
+
+ return ret;
+}
+
+static inline int rsb_read_cmd(struct rsb_controller *ctrl, u8 rtaddr,
+ u8 addr, u32 *buf, size_t len)
+{
+ int ret;
+
+ if (!ctrl || !ctrl->read_cmd || ctrl->dev.type != &rsb_ctrl_type)
+ return -EINVAL;
+
+ mutex_lock(&ctrl->lock);
+ ret = ctrl->read_cmd(ctrl, rtaddr, addr, buf, len);
+ mutex_unlock(&ctrl->lock);
+
+ return ret;
+}
+
+static inline int rsb_write_cmd(struct rsb_controller *ctrl, u8 rtaddr,
+ u8 addr, const u32 *buf, size_t len)
+{
+ int ret;
+
+ if (!ctrl || !ctrl->write_cmd || ctrl->dev.type != &rsb_ctrl_type)
+ return -EINVAL;
+
+ mutex_lock(&ctrl->lock);
+ ret = ctrl->write_cmd(ctrl, rtaddr, addr, buf, len);
+ mutex_unlock(&ctrl->lock);
+
+ return ret;
+}
+
+/**
+ * rsb_register_read() - register read
+ * @rdev: RSB device.
+ * @addr: slave register address.
+ * @buf: buffer to be populated with data from the Slave.
+ * @size: width of the slave register in bytes
+ *
+ * Reads data from a Slave device register.
+ */
+int rsb_register_read(struct rsb_device *rdev, u8 addr, u32 *buf, int size)
+{
+ switch (size) {
+ case 1:
+ case 2:
+ case 4:
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ return rsb_read_cmd(rdev->ctrl, rdev->rtaddr, addr, buf, size);
+}
+EXPORT_SYMBOL_GPL(rsb_register_read);
+
+/**
+ * rsb_register_write() - register write
+ * @rdev: RSB device
+ * @addr: slave register address.
+ * @data: buffer containing the data to be transferred to the Slave.
+ * @size: width of the slave register in bytes
+ *
+ * Writes data to a Slave device register.
+ */
+int rsb_register_write(struct rsb_device *rdev, u8 addr, u32 data, int size)
+{
+ switch (size) {
+ case 1:
+ case 2:
+ case 4:
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ return rsb_write_cmd(rdev->ctrl, rdev->rtaddr, addr, &data, size);
+}
+EXPORT_SYMBOL_GPL(rsb_register_write);
+
+static struct bus_type rsb_bus_type;
+
+static int rsb_device_probe(struct device *dev)
+{
+ const struct rsb_driver *drv = to_rsb_driver(dev->driver);
+ struct rsb_device *rsb = to_rsb_device(dev);
+ int ret;
+
+ if (dev->type != &rsb_dev_type)
+ return 0;
+
+ if (!drv->probe)
+ return -ENODEV;
+
+ if (!rsb->irq) {
+ int irq = -ENOENT;
+
+ if (dev->of_node)
+ irq = of_irq_get(dev->of_node, 0);
+
+ if (irq == -EPROBE_DEFER)
+ return irq;
+ if (irq < 0)
+ irq = 0;
+
+ rsb->irq = irq;
+ }
+
+ ret = of_clk_set_defaults(dev->of_node, false);
+ if (ret < 0)
+ return ret;
+
+ return drv->probe(rsb);
+}
+
+static int rsb_device_remove(struct device *dev)
+{
+ const struct rsb_driver *drv = to_rsb_driver(dev->driver);
+
+ if (dev->type != &rsb_dev_type)
+ return 0;
+
+ return drv->remove(to_rsb_device(dev));
+}
+
+static struct bus_type rsb_bus_type = {
+ .name = "rsb",
+ .match = rsb_device_match,
+ .probe = rsb_device_probe,
+ .remove = rsb_device_remove,
+};
+
+/**
+ * rsb_device_alloc() - Allocate a new RSB device
+ * @ctrl: associated controller
+ *
+ * Caller is responsible for either calling rsb_device_add() to add the
+ * newly allocated controller, or calling rsb_device_put() to discard it.
+ */
+static struct rsb_device *rsb_device_alloc(struct rsb_controller *ctrl)
+{
+ struct rsb_device *rdev;
+
+ rdev = kzalloc(sizeof(*rdev), GFP_KERNEL);
+ if (!rdev)
+ return NULL;
+
+ rdev->ctrl = ctrl;
+ device_initialize(&rdev->dev);
+ rdev->dev.parent = &ctrl->dev;
+ rdev->dev.bus = &rsb_bus_type;
+ rdev->dev.type = &rsb_dev_type;
+ return rdev;
+}
+
+static inline void rsb_device_put(struct rsb_device *rdev)
+{
+ if (rdev)
+ put_device(&rdev->dev);
+}
+
+/* 15 valid runtime addresses for RSB slaves */
+static const u8 rsb_valid_rtaddr[] = {
+ 0x17, 0x2d, 0x3a, 0x4e, 0x59, 0x63, 0x74, 0x8b,
+ 0x9c, 0xa6, 0xb1, 0xc5, 0xd2, 0xe8, 0xff,
+};
+
+static inline int rsb_check_rt_addr(u8 addr)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(rsb_valid_rtaddr); i++)
+ if (addr == rsb_valid_rtaddr[i])
+ return 0;
+
+ return -EINVAL;
+}
+
+/**
+ * rsb_device_add() - add a device previously constructed via rsb_device_alloc()
+ * @rdev: rsb_device to be added
+ */
+static int rsb_device_add(struct rsb_device *rdev)
+{
+ struct rsb_controller *ctrl = rdev->ctrl;
+ int err;
+
+ dev_set_name(&rdev->dev, "%d-%02x", ctrl->nr, rdev->rtaddr);
+
+ err = device_add(&rdev->dev);
+ if (err < 0) {
+ dev_err(&rdev->dev, "Can't add %s, status %d\n",
+ dev_name(&rdev->dev), err);
+ goto err_device_add;
+ }
+
+ dev_dbg(&rdev->dev, "device %s registered\n", dev_name(&rdev->dev));
+
+err_device_add:
+ return err;
+}
+
+/**
+ * rsb_device_unregister(): unregister an RSB device
+ * @rdev: rsb_device to be removed
+ */
+static void rsb_device_unregister(struct rsb_device *rdev)
+{
+ device_unregister(&rdev->dev);
+}
+
+/**
+ * rsb_controller_alloc() - Allocate a new RSB controller
+ * @parent: parent device
+ * @size: size of private data
+ *
+ * Caller is responsible for either calling rsb_controller_add() to add the
+ * newly allocated controller, or calling rsb_controller_put() to discard it.
+ * The allocated private data region may be accessed via
+ * rsb_controller_get_drvdata()
+ */
+struct rsb_controller *rsb_controller_alloc(struct device *parent, size_t size)
+{
+ struct rsb_controller *ctrl;
+ int id;
+
+ if (WARN_ON(!parent))
+ return NULL;
+
+ ctrl = kzalloc(sizeof(*ctrl) + size, GFP_KERNEL);
+ if (!ctrl)
+ return NULL;
+
+ device_initialize(&ctrl->dev);
+ mutex_init(&ctrl->lock);
+ ctrl->dev.type = &rsb_ctrl_type;
+ ctrl->dev.bus = &rsb_bus_type;
+ ctrl->dev.parent = parent;
+ ctrl->dev.of_node = parent->of_node;
+ rsb_controller_set_drvdata(ctrl, &ctrl[1]);
+
+ id = ida_simple_get(&ctrl_ida, 0, 0, GFP_KERNEL);
+ if (id < 0) {
+ dev_err(parent,
+ "unable to allocate RSB controller identifier.\n");
+ rsb_controller_put(ctrl);
+ return NULL;
+ }
+
+ ctrl->nr = id;
+ dev_set_name(&ctrl->dev, "rsb-%d", id);
+ dev_dbg(&ctrl->dev, "allocated controller 0x%p id %d\n", ctrl, id);
+
+ return ctrl;
+}
+EXPORT_SYMBOL_GPL(rsb_controller_alloc);
+
+static void of_rsb_register_devices(struct rsb_controller *ctrl)
+{
+ struct device_node *node;
+ int err;
+ u32 reg[2];
+
+ if (!ctrl->dev.of_node)
+ return;
+
+ /* Runtime addresses for all slaves should be set first */
+ for_each_available_child_of_node(ctrl->dev.of_node, node) {
+ dev_dbg(&ctrl->dev, "setting child %s runtime address\n",
+ node->full_name);
+
+ err = of_property_read_u32_array(node, "reg", reg, 2);
+ if (err) {
+ dev_err(&ctrl->dev,
+ "node %s err (%d) does not have 'reg' property\n",
+ node->full_name, err);
+ continue;
+ }
+
+ if (reg[0] > 0xff || rsb_check_rt_addr(reg[0]) < 0) {
+ dev_err(&ctrl->dev,
+ "invalid runtime address on node %s\n",
+ node->full_name);
+ continue;
+ }
+
+ /* This fails if the slave device was already initialized */
+ err = rsb_rtsaddr_cmd(ctrl, (u16)reg[1], (u8)reg[0]);
+ if (err)
+ dev_info(&ctrl->dev,
+ "failed to set runtime address: %d\n", err);
+ }
+
+ for_each_available_child_of_node(ctrl->dev.of_node, node) {
+ struct rsb_device *rdev;
+
+ dev_dbg(&ctrl->dev, "adding child %s\n", node->full_name);
+
+ err = of_property_read_u32_array(node, "reg", reg, 2);
+ if (err)
+ continue;
+
+ if (reg[0] > 0xff || rsb_check_rt_addr(reg[0]) < 0)
+ continue;
+
+ rdev = rsb_device_alloc(ctrl);
+ if (!rdev)
+ continue;
+
+ rdev->dev.of_node = node;
+ rdev->rtaddr = (u8)reg[0];
+ rdev->hwaddr = (u16)reg[1];
+
+ err = rsb_device_add(rdev);
+ if (err) {
+ dev_err(&rdev->dev, "failed to add device: %d\n", err);
+ rsb_device_put(rdev);
+ }
+ }
+}
+
+/**
+ * rsb_controller_add() - Add an RSB controller
+ * @ctrl: controller to be registered.
+ *
+ * Register a controller previously allocated via rsb_controller_alloc() with
+ * the RSB core.
+ */
+int rsb_controller_add(struct rsb_controller *ctrl)
+{
+ int ret;
+
+ /* Can't register until after driver model init */
+ if (WARN_ON(!rsb_bus_type.p))
+ return -EAGAIN;
+
+ ret = device_add(&ctrl->dev);
+ if (ret)
+ return ret;
+
+ /*
+ * Send RSB init sequence on the bus. This fails if the bus was
+ * already initialized.
+ */
+ ret = rsb_init_cmd(ctrl);
+ if (ret)
+ dev_info(&ctrl->dev, "RSB init sequence failed: %d\n", ret);
+
+ if (IS_ENABLED(CONFIG_OF))
+ of_rsb_register_devices(ctrl);
+
+ dev_dbg(&ctrl->dev, "rsb-%d registered: dev:%p\n",
+ ctrl->nr, &ctrl->dev);
+
+ return 0;
+};
+EXPORT_SYMBOL_GPL(rsb_controller_add);
+
+/* Remove a device associated with a controller */
+static int rsb_ctrl_remove_device(struct device *dev, void *data)
+{
+ struct rsb_device *rsb = to_rsb_device(dev);
+
+ if (dev->type == &rsb_dev_type)
+ rsb_device_unregister(rsb);
+ return 0;
+}
+
+/**
+ * rsb_controller_remove(): remove an RSB controller
+ * @ctrl: controller to remove
+ *
+ * Remove a RSB controller. Caller is responsible for calling
+ * rsb_controller_put() to discard the allocated controller.
+ */
+void rsb_controller_remove(struct rsb_controller *ctrl)
+{
+ int dummy;
+
+ if (!ctrl)
+ return;
+
+ dummy = device_for_each_child(&ctrl->dev, NULL,
+ rsb_ctrl_remove_device);
+ mutex_destroy(&ctrl->lock);
+ device_del(&ctrl->dev);
+}
+EXPORT_SYMBOL_GPL(rsb_controller_remove);
+
+/**
+ * rsb_driver_register() - Register device driver with RSB core
+ * @rdrv: device driver to be associated with slave-device.
+ *
+ * This API will register the client driver with the RSB framework.
+ * It is typically called from the driver's module-init function.
+ */
+int rsb_driver_register(struct rsb_driver *rdrv)
+{
+ rdrv->driver.bus = &rsb_bus_type;
+ return driver_register(&rdrv->driver);
+}
+EXPORT_SYMBOL_GPL(rsb_driver_register);
+
+static void __exit rsb_exit(void)
+{
+ bus_unregister(&rsb_bus_type);
+}
+module_exit(rsb_exit);
+
+static int __init rsb_init(void)
+{
+ return bus_register(&rsb_bus_type);
+}
+postcore_initcall(rsb_init);
+
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("Reduce Serial Bus (RSB) core module");
+MODULE_ALIAS("platform:rsb");
diff --git a/include/linux/rsb.h b/include/linux/rsb.h
new file mode 100644
index 000000000000..51a53468f547
--- /dev/null
+++ b/include/linux/rsb.h
@@ -0,0 +1,144 @@
+/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * 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 _LINUX_RSB_H
+#define _LINUX_RSB_H
+
+#include <linux/device.h>
+#include <linux/mod_devicetable.h>
+#include <linux/mutex.h>
+#include <linux/types.h>
+
+/**
+ * struct rsb_device - Basic representation of an RSB device
+ * @dev: Driver model representation of the device.
+ * @ctrl: RSB controller managing the bus hosting this device.
+ * @rtaddr: This device's runtime address
+ * @hwaddr: This device's hardware address
+ */
+struct rsb_device {
+ struct device dev;
+ struct rsb_controller *ctrl;
+ int irq;
+ u8 rtaddr;
+ u16 hwaddr;
+};
+
+static inline struct rsb_device *to_rsb_device(struct device *d)
+{
+ return container_of(d, struct rsb_device, dev);
+}
+
+static inline void *rsb_device_get_drvdata(const struct rsb_device *rdev)
+{
+ return dev_get_drvdata(&rdev->dev);
+}
+
+static inline void rsb_device_set_drvdata(struct rsb_device *rdev, void *data)
+{
+ dev_set_drvdata(&rdev->dev, data);
+}
+
+/**
+ * struct rsb_controller - interface to the RSB master controller
+ * @dev: Driver model representation of the device.
+ * @nr: board-specific number identifier for this controller/bus
+ * @init_cmd: sends a device initialization command sequence on the bus.
+ * @rtsaddr_cmd: sends a "set runtime address" command sequence on the bus.
+ * @read_cmd: sends a register read command sequence on the RSB bus.
+ * @write_cmd: sends a register write command sequence on the RSB bus.
+ */
+struct rsb_controller {
+ struct device dev;
+ unsigned int nr;
+ struct mutex lock; /* serialize access to the bus */
+ int (*init_cmd)(struct rsb_controller *ctrl);
+ int (*rtsaddr_cmd)(struct rsb_controller *ctrl,
+ u16 hwaddr, u8 rtaddr);
+ int (*read_cmd)(struct rsb_controller *ctrl, u8 rtaddr,
+ u8 addr, u32 *buf, size_t len);
+ int (*write_cmd)(struct rsb_controller *ctrl, u8 rtaddr,
+ u8 addr, const u32 *buf, size_t len);
+};
+
+static inline struct rsb_controller *to_rsb_controller(struct device *d)
+{
+ return container_of(d, struct rsb_controller, dev);
+}
+
+static inline
+void *rsb_controller_get_drvdata(const struct rsb_controller *ctrl)
+{
+ return dev_get_drvdata(&ctrl->dev);
+}
+
+static inline void rsb_controller_set_drvdata(struct rsb_controller *ctrl,
+ void *data)
+{
+ dev_set_drvdata(&ctrl->dev, data);
+}
+
+struct rsb_controller *rsb_controller_alloc(struct device *parent,
+ size_t size);
+
+/**
+ * rsb_controller_put() - decrement controller refcount
+ * @ctrl RSB controller.
+ */
+static inline void rsb_controller_put(struct rsb_controller *ctrl)
+{
+ if (ctrl) {
+ mutex_destroy(&ctrl->lock);
+ put_device(&ctrl->dev);
+ }
+}
+
+int rsb_controller_add(struct rsb_controller *ctrl);
+void rsb_controller_remove(struct rsb_controller *ctrl);
+
+/**
+ * struct rsb_driver - RSB slave device driver
+ * @driver: RSB device drivers should initialize name and owner field of
+ * this structure.
+ * @probe: binds this driver to a RSB device.
+ * @remove: unbinds this driver from the RSB device.
+ */
+struct rsb_driver {
+ struct device_driver driver;
+ int (*probe)(struct rsb_device *rdev);
+ int (*remove)(struct rsb_device *rdev);
+};
+
+static inline struct rsb_driver *to_rsb_driver(struct device_driver *d)
+{
+ return container_of(d, struct rsb_driver, driver);
+}
+
+int rsb_driver_register(struct rsb_driver *rdrv);
+
+/**
+ * rsb_driver_unregister() - unregister an RSB client driver
+ * @rdrv: the driver to unregister
+ */
+static inline void rsb_driver_unregister(struct rsb_driver *rdrv)
+{
+ if (rdrv)
+ driver_unregister(&rdrv->driver);
+}
+
+#define module_rsb_driver(__rsb_driver) \
+ module_driver(__rsb_driver, rsb_driver_register, \
+ rsb_driver_unregister)
+
+int rsb_register_read(struct rsb_device *rdev, u8 addr, u32 *buf, int size);
+int rsb_register_write(struct rsb_device *rdev, u8 addr, u32 data, int size);
+
+#endif
--
2.5.0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Mark Brown <broonie@kernel.org> |
|---|---|
| Date | 2015-08-20 19:10 +0200 |
| Subject | Re: [PATCH v3 3/8] rsb: Linux driver framework for Reduced Serial Bus (RSB) |
| Message-ID | <pZBvI-2L0-3@gated-at.bofh.it> |
| In reply to | #1209611 |
[Multipart message — attachments visible in raw view] — view raw
On Wed, Aug 19, 2015 at 12:20:04PM +0800, Chen-Yu Tsai wrote: > Reduced Serial Bus (RSB) is an Allwinner proprietery interface > used to communicate with PMICs and other peripheral ICs. > drivers/rsb/Kconfig | 11 ++ > drivers/rsb/Makefile | 4 + > drivers/rsb/rsb-core.c | 511 +++++++++++++++++++++++++++++++++++++++++++++++++ Based on the changelog and what you were saying in your other mail about this being very Allwinner specific I think the current trend would be to put this into drivers/soc rather than making a new top level directory in drivers.
[toc] | [prev] | [next] | [standalone]
| From | Chen-Yu Tsai <wens@csie.org> |
|---|---|
| Date | 2015-08-19 06:30 +0200 |
| Subject | [PATCH v3 1/8] rsb: Add generic Reduced Serial Bus (RSB) controller binding documentation |
| Message-ID | <pZ3aG-3oT-9@gated-at.bofh.it> |
| In reply to | #1209609 |
Reduced Serial Bus is a proprietary 2-line push-pull serial bus
supporting multiple slave devices.
It was developed by Allwinner, Inc. and used by Allwinner and X-Powers,
Inc. for their line of PMICs and other peripheral ICs.
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
Documentation/devicetree/bindings/rsb/rsb.txt | 50 +++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
create mode 100644 Documentation/devicetree/bindings/rsb/rsb.txt
diff --git a/Documentation/devicetree/bindings/rsb/rsb.txt b/Documentation/devicetree/bindings/rsb/rsb.txt
new file mode 100644
index 000000000000..0b027948ca9c
--- /dev/null
+++ b/Documentation/devicetree/bindings/rsb/rsb.txt
@@ -0,0 +1,50 @@
+Reduced Serial Bus (RSB) Controller
+
+This document defines a generic set of bindings for use by RSB controllers.
+A controller is modelled in device tree as a node with zero or more child
+nodes, each representing a unique slave device on the bus.
+
+Required properties:
+
+ - #address-cells : must be 2
+ - #size-cells : must be 0
+
+Optional properties:
+
+ - clock-frequency : Desired bus clock frequency in Hz. Maximum is 20 MHz.
+
+Child nodes:
+
+An RSB controller node can contain zero or more child nodes representing
+slave devices on the bus. Child 'reg' properties are specified as a
+runtime address, hardware address pair. The hardware address is hardwired
+in the device, which can normally be found in the datasheet. The runtime
+address is set by software. No 2 devices on the same bus shall have the
+same runtime address.
+
+Valid runtime addresses - There are only 15 valid runtime addresses:
+
+ 0x17, 0x2d, 0x3a, 0x4e, 0x59, 0x63, 0x74, 0x8b,
+ 0x9c, 0xa6, 0xb1, 0xc5, 0xd2, 0xe8, 0xff
+
+It is highly recommended that one choose the same runtime addresses as
+vendor BSPs use so that a) the addresses remain the same across different
+software systems, and b) addresses of supported and listed slave devices
+don't conflict with unsupported or not yet listed devices.
+
+Example:
+
+ rsb@... {
+ compatible = "...";
+ reg = <...>;
+ /* ... */
+ #address-cells = <2>;
+ #size-cells = <0>;
+
+ pmic@2d {
+ compatible = "...";
+ reg = <0x2d 0x3e3>;
+
+ /* ... */
+ };
+ };
--
2.5.0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Maxime Ripard <maxime.ripard@free-electrons.com> |
|---|---|
| Date | 2015-08-20 17:10 +0200 |
| Subject | Re: [PATCH v3 1/8] rsb: Add generic Reduced Serial Bus (RSB) controller binding documentation |
| Message-ID | <pZzDz-8vO-15@gated-at.bofh.it> |
| In reply to | #1209612 |
[Multipart message — attachments visible in raw view] — view raw
Hi,
Thanks a lot for working on this.
On Wed, Aug 19, 2015 at 12:20:02PM +0800, Chen-Yu Tsai wrote:
> Reduced Serial Bus is a proprietary 2-line push-pull serial bus
> supporting multiple slave devices.
>
> It was developed by Allwinner, Inc. and used by Allwinner and X-Powers,
> Inc. for their line of PMICs and other peripheral ICs.
>
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
> ---
> Documentation/devicetree/bindings/rsb/rsb.txt | 50 +++++++++++++++++++++++++++
> 1 file changed, 50 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/rsb/rsb.txt
>
> diff --git a/Documentation/devicetree/bindings/rsb/rsb.txt b/Documentation/devicetree/bindings/rsb/rsb.txt
> new file mode 100644
> index 000000000000..0b027948ca9c
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/rsb/rsb.txt
> @@ -0,0 +1,50 @@
> +Reduced Serial Bus (RSB) Controller
> +
> +This document defines a generic set of bindings for use by RSB controllers.
> +A controller is modelled in device tree as a node with zero or more child
> +nodes, each representing a unique slave device on the bus.
> +
> +Required properties:
> +
> + - #address-cells : must be 2
> + - #size-cells : must be 0
> +
> +Optional properties:
> +
> + - clock-frequency : Desired bus clock frequency in Hz. Maximum is 20 MHz.
What is the default if not set?
> +
> +Child nodes:
> +
> +An RSB controller node can contain zero or more child nodes representing
> +slave devices on the bus. Child 'reg' properties are specified as a
> +runtime address, hardware address pair. The hardware address is hardwired
> +in the device, which can normally be found in the datasheet. The runtime
> +address is set by software. No 2 devices on the same bus shall have the
> +same runtime address.
> +
> +Valid runtime addresses - There are only 15 valid runtime addresses:
> +
> + 0x17, 0x2d, 0x3a, 0x4e, 0x59, 0x63, 0x74, 0x8b,
> + 0x9c, 0xa6, 0xb1, 0xc5, 0xd2, 0xe8, 0xff
> +
> +It is highly recommended that one choose the same runtime addresses as
> +vendor BSPs use so that a) the addresses remain the same across different
> +software systems, and b) addresses of supported and listed slave devices
> +don't conflict with unsupported or not yet listed devices.
I'd expect to have the hardware address first, but maybe it's just me
:)
> +Example:
> +
> + rsb@... {
> + compatible = "...";
> + reg = <...>;
> + /* ... */
> + #address-cells = <2>;
> + #size-cells = <0>;
> +
> + pmic@2d {
The unit-address should be 2d,3e3.
> + compatible = "...";
> + reg = <0x2d 0x3e3>;
> +
> + /* ... */
> + };
> + };
> --
> 2.5.0
>
--
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
[toc] | [prev] | [next] | [standalone]
| From | Chen-Yu Tsai <wens@csie.org> |
|---|---|
| Date | 2015-08-20 18:00 +0200 |
| Subject | Re: [PATCH v3 1/8] rsb: Add generic Reduced Serial Bus (RSB) controller binding documentation |
| Message-ID | <pZApX-YM-7@gated-at.bofh.it> |
| In reply to | #1210582 |
On Thu, Aug 20, 2015 at 11:08 PM, Maxime Ripard
<maxime.ripard@free-electrons.com> wrote:
> Hi,
>
> Thanks a lot for working on this.
>
> On Wed, Aug 19, 2015 at 12:20:02PM +0800, Chen-Yu Tsai wrote:
>> Reduced Serial Bus is a proprietary 2-line push-pull serial bus
>> supporting multiple slave devices.
>>
>> It was developed by Allwinner, Inc. and used by Allwinner and X-Powers,
>> Inc. for their line of PMICs and other peripheral ICs.
>>
>> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
>> ---
>> Documentation/devicetree/bindings/rsb/rsb.txt | 50 +++++++++++++++++++++++++++
>> 1 file changed, 50 insertions(+)
>> create mode 100644 Documentation/devicetree/bindings/rsb/rsb.txt
>>
>> diff --git a/Documentation/devicetree/bindings/rsb/rsb.txt b/Documentation/devicetree/bindings/rsb/rsb.txt
>> new file mode 100644
>> index 000000000000..0b027948ca9c
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/rsb/rsb.txt
>> @@ -0,0 +1,50 @@
>> +Reduced Serial Bus (RSB) Controller
>> +
>> +This document defines a generic set of bindings for use by RSB controllers.
>> +A controller is modelled in device tree as a node with zero or more child
>> +nodes, each representing a unique slave device on the bus.
>> +
>> +Required properties:
>> +
>> + - #address-cells : must be 2
>> + - #size-cells : must be 0
>> +
>> +Optional properties:
>> +
>> + - clock-frequency : Desired bus clock frequency in Hz. Maximum is 20 MHz.
>
> What is the default if not set?
Presently the driver would have it default to 1 MHz, Which doesn't match
the driver binding. Will fix this.
>> +
>> +Child nodes:
>> +
>> +An RSB controller node can contain zero or more child nodes representing
>> +slave devices on the bus. Child 'reg' properties are specified as a
>> +runtime address, hardware address pair. The hardware address is hardwired
>> +in the device, which can normally be found in the datasheet. The runtime
>> +address is set by software. No 2 devices on the same bus shall have the
>> +same runtime address.
>> +
>> +Valid runtime addresses - There are only 15 valid runtime addresses:
>> +
>> + 0x17, 0x2d, 0x3a, 0x4e, 0x59, 0x63, 0x74, 0x8b,
>> + 0x9c, 0xa6, 0xb1, 0xc5, 0xd2, 0xe8, 0xff
>> +
>> +It is highly recommended that one choose the same runtime addresses as
>> +vendor BSPs use so that a) the addresses remain the same across different
>> +software systems, and b) addresses of supported and listed slave devices
>> +don't conflict with unsupported or not yet listed devices.
>
> I'd expect to have the hardware address first, but maybe it's just me
> :)
I don't know. It's only used at init time.
And in my latest experience, once the runtime address is set by the
bootloader, it can't be changed. My earlier experience was the opposite,
though I haven't figured out why.
>
>> +Example:
>> +
>> + rsb@... {
>> + compatible = "...";
>> + reg = <...>;
>> + /* ... */
>> + #address-cells = <2>;
>> + #size-cells = <0>;
>> +
>> + pmic@2d {
>
> The unit-address should be 2d,3e3.
Hmm... I didn't know this was legal.
>> + compatible = "...";
>> + reg = <0x2d 0x3e3>;
>> +
>> + /* ... */
>> + };
>> + };
>> --
>> 2.5.0
>>
>
> --
> Maxime Ripard, Free Electrons
> Embedded Linux, Kernel and Android engineering
> http://free-electrons.com
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Maxime Ripard <maxime.ripard@free-electrons.com> |
|---|---|
| Date | 2015-08-20 23:30 +0200 |
| Subject | Re: [PATCH v3 1/8] rsb: Add generic Reduced Serial Bus (RSB) controller binding documentation |
| Message-ID | <pZFzk-7l-9@gated-at.bofh.it> |
| In reply to | #1210603 |
[Multipart message — attachments visible in raw view] — view raw
On Thu, Aug 20, 2015 at 11:58:39PM +0800, Chen-Yu Tsai wrote: > >> +Child nodes: > >> + > >> +An RSB controller node can contain zero or more child nodes representing > >> +slave devices on the bus. Child 'reg' properties are specified as a > >> +runtime address, hardware address pair. The hardware address is hardwired > >> +in the device, which can normally be found in the datasheet. The runtime > >> +address is set by software. No 2 devices on the same bus shall have the > >> +same runtime address. > >> + > >> +Valid runtime addresses - There are only 15 valid runtime addresses: > >> + > >> + 0x17, 0x2d, 0x3a, 0x4e, 0x59, 0x63, 0x74, 0x8b, > >> + 0x9c, 0xa6, 0xb1, 0xc5, 0xd2, 0xe8, 0xff > >> + > >> +It is highly recommended that one choose the same runtime addresses as > >> +vendor BSPs use so that a) the addresses remain the same across different > >> +software systems, and b) addresses of supported and listed slave devices > >> +don't conflict with unsupported or not yet listed devices. > > > > I'd expect to have the hardware address first, but maybe it's just me > > :) > > I don't know. It's only used at init time. > > And in my latest experience, once the runtime address is set by the > bootloader, it can't be changed. My earlier experience was the opposite, > though I haven't figured out why. Note that I'm only talking about the order of runtime and hardware addresses in the reg property, having both is fine. Maxime -- Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
[toc] | [prev] | [next] | [standalone]
| From | Rob Herring <robherring2@gmail.com> |
|---|---|
| Date | 2015-08-24 00:50 +0200 |
| Subject | Re: [PATCH v3 1/8] rsb: Add generic Reduced Serial Bus (RSB) controller binding documentation |
| Message-ID | <q0Mfo-62H-11@gated-at.bofh.it> |
| In reply to | #1209612 |
On Tue, Aug 18, 2015 at 11:20 PM, Chen-Yu Tsai <wens@csie.org> wrote: > Reduced Serial Bus is a proprietary 2-line push-pull serial bus > supporting multiple slave devices. > > It was developed by Allwinner, Inc. and used by Allwinner and X-Powers, > Inc. for their line of PMICs and other peripheral ICs. > > Signed-off-by: Chen-Yu Tsai <wens@csie.org> > --- > Documentation/devicetree/bindings/rsb/rsb.txt | 50 +++++++++++++++++++++++++++ > 1 file changed, 50 insertions(+) > create mode 100644 Documentation/devicetree/bindings/rsb/rsb.txt > > diff --git a/Documentation/devicetree/bindings/rsb/rsb.txt b/Documentation/devicetree/bindings/rsb/rsb.txt > new file mode 100644 > index 000000000000..0b027948ca9c > --- /dev/null > +++ b/Documentation/devicetree/bindings/rsb/rsb.txt > @@ -0,0 +1,50 @@ > +Reduced Serial Bus (RSB) Controller > + > +This document defines a generic set of bindings for use by RSB controllers. > +A controller is modelled in device tree as a node with zero or more child > +nodes, each representing a unique slave device on the bus. > + > +Required properties: > + > + - #address-cells : must be 2 > + - #size-cells : must be 0 > + > +Optional properties: > + > + - clock-frequency : Desired bus clock frequency in Hz. Maximum is 20 MHz. > + > +Child nodes: > + > +An RSB controller node can contain zero or more child nodes representing > +slave devices on the bus. Child 'reg' properties are specified as a > +runtime address, hardware address pair. The hardware address is hardwired > +in the device, which can normally be found in the datasheet. The runtime > +address is set by software. No 2 devices on the same bus shall have the > +same runtime address. > + > +Valid runtime addresses - There are only 15 valid runtime addresses: > + > + 0x17, 0x2d, 0x3a, 0x4e, 0x59, 0x63, 0x74, 0x8b, > + 0x9c, 0xa6, 0xb1, 0xc5, 0xd2, 0xe8, 0xff > + > +It is highly recommended that one choose the same runtime addresses as > +vendor BSPs use so that a) the addresses remain the same across different > +software systems, and b) addresses of supported and listed slave devices > +don't conflict with unsupported or not yet listed devices. I fail to understand why the run-time address belongs in DT or why alignment to vendor BSP matters? I can see the desire to align DTs if the vendor OS was dependent on having this information. Having to access the vendor OS to determine what address to pick does not seem like the right way to write a DTS. It seems to me that the RSB bus driver should allocate run-time addresses dynamically. Rob -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Mark Brown <broonie@kernel.org> |
|---|---|
| Date | 2015-08-19 18:40 +0200 |
| Message-ID | <pZez8-2Yu-7@gated-at.bofh.it> |
| In reply to | #1209609 |
[Multipart message — attachments visible in raw view] — view raw
On Wed, Aug 19, 2015 at 12:20:01PM +0800, Chen-Yu Tsai wrote: > Hi everyone, > > This is my third attempt at adding support for Allwinner's Reduced > Serial Bus (RSB), which is used to communicate with PMICs and other > peripherals on their newer SoCs, such as the A23/A33/A80. This is flagged as something that is specific to the Allwinner SoCs. Why add generic regmap support rather than just implement the regmap reg_read() and reg_write() in a regmap in the controller driver? Are there expected to be other controller drivers from other vendors?
[toc] | [prev] | [next] | [standalone]
| From | Chen-Yu Tsai <wens@csie.org> |
|---|---|
| Date | 2015-08-20 04:10 +0200 |
| Message-ID | <pZnsJ-7ui-9@gated-at.bofh.it> |
| In reply to | #1209941 |
On Thu, Aug 20, 2015 at 12:32 AM, Mark Brown <broonie@kernel.org> wrote: > On Wed, Aug 19, 2015 at 12:20:01PM +0800, Chen-Yu Tsai wrote: >> Hi everyone, >> >> This is my third attempt at adding support for Allwinner's Reduced >> Serial Bus (RSB), which is used to communicate with PMICs and other >> peripherals on their newer SoCs, such as the A23/A33/A80. > > This is flagged as something that is specific to the Allwinner SoCs. > Why add generic regmap support rather than just implement the regmap > reg_read() and reg_write() in a regmap in the controller driver? Are > there expected to be other controller drivers from other vendors? I don't expect there to be any other controller drivers. And it seems at least some of the devices are dual interface (I2C/RSB). Though I don't see how its connected to the generic regmap support. Regmap is for device drivers connected to the RSB bus, not the bus controller itself. That said, there are a few RSB mfd slave devices that need support, those being the later AXP series PMICs, and AC100/AC200 audio-codec/RTC chips. The current axp20x driver already uses i2c regmaps. I could throw all the RSB-related stuff together, presumably under drivers/soc/sunxi/rsb, though that doesn't help the fact that common regmap code would be better than scattering regmap_* in various mfd drivers. Regards ChenYu -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Mark Brown <broonie@kernel.org> |
|---|---|
| Date | 2015-08-20 19:10 +0200 |
| Message-ID | <pZBvI-2L0-9@gated-at.bofh.it> |
| In reply to | #1210114 |
[Multipart message — attachments visible in raw view] — view raw
On Thu, Aug 20, 2015 at 09:59:27AM +0800, Chen-Yu Tsai wrote: > On Thu, Aug 20, 2015 at 12:32 AM, Mark Brown <broonie@kernel.org> wrote: > > This is flagged as something that is specific to the Allwinner SoCs. > > Why add generic regmap support rather than just implement the regmap > > reg_read() and reg_write() in a regmap in the controller driver? Are > > there expected to be other controller drivers from other vendors? > I don't expect there to be any other controller drivers. And it seems > at least some of the devices are dual interface (I2C/RSB). Though I > don't see how its connected to the generic regmap support. Regmap > is for device drivers connected to the RSB bus, not the bus controller > itself. The point here is that you can use regmap for a custom controller without having to implement a bus, to repeat what I said: | > Why add generic regmap support rather than just implement the regmap | > reg_read() and reg_write() in a regmap in the controller driver? Are > I could throw all the RSB-related stuff together, presumably under > drivers/soc/sunxi/rsb, though that doesn't help the fact that common > regmap code would be better than scattering regmap_* in various mfd > drivers. If there is only one controller driver you just have a single call into that driver in the client device which gives you the same level of shared code, having a wrapper layer in regmap that puts regmap_ functions around the equivalent controller specific functions isn't really adding a huge amount. It's a similar thing to the way we just reuse the platform bus for basic buses rather than copying it to make new bus types, we don't need to create lots of new boilerplate regmap types that are just really basic wrappers. There are a lot of these custom buses that people have.
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web