2 * RSB (Reduced Serial Bus) driver.
4 * Author: Chen-Yu Tsai <wens@csie.org>
6 * This file is licensed under the terms of the GNU General Public License
7 * version 2. This program is licensed "as is" without any warranty of any
8 * kind, whether express or implied.
10 * The RSB controller looks like an SMBus controller which only supports
11 * byte and word data transfers. But, it differs from standard SMBus
12 * protocol on several aspects:
13 * - it uses addresses set at runtime to address slaves. Runtime addresses
14 * are sent to slaves using their 12bit hardware addresses. Up to 15
15 * runtime addresses are available.
16 * - it adds a parity bit every 8bits of data and address for read and
17 * write accesses; this replaces the ack bit
18 * - only one read access is required to read a byte (instead of a write
19 * followed by a read access in standard SMBus protocol)
20 * - there's no Ack bit after each read access
22 * This means this bus cannot be used to interface with standard SMBus
23 * devices. Devices known to support this interface include the AXP223,
24 * AXP809, and AXP806 PMICs, and the AC100 audio codec, all from X-Powers.
26 * A description of the operation and wire protocol can be found in the
27 * RSB section of Allwinner's A80 user manual, which can be found at
29 * https://github.com/allwinner-zh/documents/tree/master/A80
31 * This document is officially released by Allwinner.
33 * This driver is based on i2c-sun6i-p2wi.c, the P2WI bus driver.
37 #include <linux/clk.h>
38 #include <linux/clk/clk-conf.h>
39 #include <linux/device.h>
40 #include <linux/interrupt.h>
42 #include <linux/iopoll.h>
43 #include <linux/module.h>
45 #include <linux/of_irq.h>
46 #include <linux/of_platform.h>
47 #include <linux/platform_device.h>
49 #include <linux/pm_runtime.h>
50 #include <linux/regmap.h>
51 #include <linux/reset.h>
52 #include <linux/slab.h>
53 #include <linux/sunxi-rsb.h>
54 #include <linux/types.h>
57 #define RSB_CTRL 0x0 /* Global control */
58 #define RSB_CCR 0x4 /* Clock control */
59 #define RSB_INTE 0x8 /* Interrupt controls */
60 #define RSB_INTS 0xc /* Interrupt status */
61 #define RSB_ADDR 0x10 /* Address to send with read/write command */
62 #define RSB_DATA 0x1c /* Data to read/write */
63 #define RSB_LCR 0x24 /* Line control */
64 #define RSB_DMCR 0x28 /* Device mode (init) control */
65 #define RSB_CMD 0x2c /* RSB Command */
66 #define RSB_DAR 0x30 /* Device address / runtime address */
69 #define RSB_CTRL_START_TRANS BIT(7)
70 #define RSB_CTRL_ABORT_TRANS BIT(6)
71 #define RSB_CTRL_GLOBAL_INT_ENB BIT(1)
72 #define RSB_CTRL_SOFT_RST BIT(0)
75 #define RSB_CCR_SDA_OUT_DELAY(v) (((v) & 0x7) << 8)
76 #define RSB_CCR_MAX_CLK_DIV 0xff
77 #define RSB_CCR_CLK_DIV(v) ((v) & RSB_CCR_MAX_CLK_DIV)
80 #define RSB_INTS_TRANS_ERR_ACK BIT(16)
81 #define RSB_INTS_TRANS_ERR_DATA_BIT(v) (((v) >> 8) & 0xf)
82 #define RSB_INTS_TRANS_ERR_DATA GENMASK(11, 8)
83 #define RSB_INTS_LOAD_BSY BIT(2)
84 #define RSB_INTS_TRANS_ERR BIT(1)
85 #define RSB_INTS_TRANS_OVER BIT(0)
88 #define RSB_LCR_SCL_STATE BIT(5)
89 #define RSB_LCR_SDA_STATE BIT(4)
90 #define RSB_LCR_SCL_CTL BIT(3)
91 #define RSB_LCR_SCL_CTL_EN BIT(2)
92 #define RSB_LCR_SDA_CTL BIT(1)
93 #define RSB_LCR_SDA_CTL_EN BIT(0)
95 /* DEVICE MODE CTRL field values */
96 #define RSB_DMCR_DEVICE_START BIT(31)
97 #define RSB_DMCR_MODE_DATA (0x7c << 16)
98 #define RSB_DMCR_MODE_REG (0x3e << 8)
99 #define RSB_DMCR_DEV_ADDR 0x00
102 #define RSB_CMD_RD8 0x8b
103 #define RSB_CMD_RD16 0x9c
104 #define RSB_CMD_RD32 0xa6
105 #define RSB_CMD_WR8 0x4e
106 #define RSB_CMD_WR16 0x59
107 #define RSB_CMD_WR32 0x63
108 #define RSB_CMD_STRA 0xe8
111 #define RSB_DAR_RTA(v) (((v) & 0xff) << 16)
112 #define RSB_DAR_DA(v) ((v) & 0xffff)
114 #define RSB_MAX_FREQ 20000000
116 #define RSB_CTRL_NAME "sunxi-rsb"
118 struct sunxi_rsb_addr_map {
127 struct reset_control *rstc;
128 struct completion complete;
134 /* bus / slave device related functions */
135 static struct bus_type sunxi_rsb_bus;
137 static int sunxi_rsb_device_match(struct device *dev, struct device_driver *drv)
139 return of_driver_match_device(dev, drv);
142 static int sunxi_rsb_device_probe(struct device *dev)
144 const struct sunxi_rsb_driver *drv = to_sunxi_rsb_driver(dev->driver);
145 struct sunxi_rsb_device *rdev = to_sunxi_rsb_device(dev);
155 irq = of_irq_get(dev->of_node, 0);
157 if (irq == -EPROBE_DEFER)
165 ret = of_clk_set_defaults(dev->of_node, false);
169 return drv->probe(rdev);
172 static int sunxi_rsb_device_remove(struct device *dev)
174 const struct sunxi_rsb_driver *drv = to_sunxi_rsb_driver(dev->driver);
176 drv->remove(to_sunxi_rsb_device(dev));
181 static struct bus_type sunxi_rsb_bus = {
182 .name = RSB_CTRL_NAME,
183 .match = sunxi_rsb_device_match,
184 .probe = sunxi_rsb_device_probe,
185 .remove = sunxi_rsb_device_remove,
186 .uevent = of_device_uevent_modalias,
189 static void sunxi_rsb_dev_release(struct device *dev)
191 struct sunxi_rsb_device *rdev = to_sunxi_rsb_device(dev);
197 * sunxi_rsb_device_create() - allocate and add an RSB device
198 * @rsb: RSB controller
199 * @node: RSB slave device node
200 * @hwaddr: RSB slave hardware address
201 * @rtaddr: RSB slave runtime address
203 static struct sunxi_rsb_device *sunxi_rsb_device_create(struct sunxi_rsb *rsb,
204 struct device_node *node, u16 hwaddr, u8 rtaddr)
207 struct sunxi_rsb_device *rdev;
209 rdev = kzalloc(sizeof(*rdev), GFP_KERNEL);
211 return ERR_PTR(-ENOMEM);
214 rdev->hwaddr = hwaddr;
215 rdev->rtaddr = rtaddr;
216 rdev->dev.bus = &sunxi_rsb_bus;
217 rdev->dev.parent = rsb->dev;
218 rdev->dev.of_node = node;
219 rdev->dev.release = sunxi_rsb_dev_release;
221 dev_set_name(&rdev->dev, "%s-%x", RSB_CTRL_NAME, hwaddr);
223 err = device_register(&rdev->dev);
225 dev_err(&rdev->dev, "Can't add %s, status %d\n",
226 dev_name(&rdev->dev), err);
230 dev_dbg(&rdev->dev, "device %s registered\n", dev_name(&rdev->dev));
233 put_device(&rdev->dev);
239 * sunxi_rsb_device_unregister(): unregister an RSB device
240 * @rdev: rsb_device to be removed
242 static void sunxi_rsb_device_unregister(struct sunxi_rsb_device *rdev)
244 device_unregister(&rdev->dev);
247 static int sunxi_rsb_remove_devices(struct device *dev, void *data)
249 struct sunxi_rsb_device *rdev = to_sunxi_rsb_device(dev);
251 if (dev->bus == &sunxi_rsb_bus)
252 sunxi_rsb_device_unregister(rdev);
258 * sunxi_rsb_driver_register() - Register device driver with RSB core
259 * @rdrv: device driver to be associated with slave-device.
261 * This API will register the client driver with the RSB framework.
262 * It is typically called from the driver's module-init function.
264 int sunxi_rsb_driver_register(struct sunxi_rsb_driver *rdrv)
266 rdrv->driver.bus = &sunxi_rsb_bus;
267 return driver_register(&rdrv->driver);
269 EXPORT_SYMBOL_GPL(sunxi_rsb_driver_register);
271 /* common code that starts a transfer */
272 static int _sunxi_rsb_run_xfer(struct sunxi_rsb *rsb)
274 if (readl(rsb->regs + RSB_CTRL) & RSB_CTRL_START_TRANS) {
275 dev_dbg(rsb->dev, "RSB transfer still in progress\n");
279 reinit_completion(&rsb->complete);
281 writel(RSB_INTS_LOAD_BSY | RSB_INTS_TRANS_ERR | RSB_INTS_TRANS_OVER,
282 rsb->regs + RSB_INTE);
283 writel(RSB_CTRL_START_TRANS | RSB_CTRL_GLOBAL_INT_ENB,
284 rsb->regs + RSB_CTRL);
286 if (!wait_for_completion_io_timeout(&rsb->complete,
287 msecs_to_jiffies(100))) {
288 dev_dbg(rsb->dev, "RSB timeout\n");
290 /* abort the transfer */
291 writel(RSB_CTRL_ABORT_TRANS, rsb->regs + RSB_CTRL);
293 /* clear any interrupt flags */
294 writel(readl(rsb->regs + RSB_INTS), rsb->regs + RSB_INTS);
299 if (rsb->status & RSB_INTS_LOAD_BSY) {
300 dev_dbg(rsb->dev, "RSB busy\n");
304 if (rsb->status & RSB_INTS_TRANS_ERR) {
305 if (rsb->status & RSB_INTS_TRANS_ERR_ACK) {
306 dev_dbg(rsb->dev, "RSB slave nack\n");
310 if (rsb->status & RSB_INTS_TRANS_ERR_DATA) {
311 dev_dbg(rsb->dev, "RSB transfer data error\n");
319 static int sunxi_rsb_read(struct sunxi_rsb *rsb, u8 rtaddr, u8 addr,
320 u32 *buf, size_t len)
339 dev_err(rsb->dev, "Invalid access width: %zd\n", len);
343 ret = pm_runtime_resume_and_get(rsb->dev);
347 mutex_lock(&rsb->lock);
349 writel(addr, rsb->regs + RSB_ADDR);
350 writel(RSB_DAR_RTA(rtaddr), rsb->regs + RSB_DAR);
351 writel(cmd, rsb->regs + RSB_CMD);
353 ret = _sunxi_rsb_run_xfer(rsb);
357 *buf = readl(rsb->regs + RSB_DATA) & GENMASK(len * 8 - 1, 0);
360 mutex_unlock(&rsb->lock);
362 pm_runtime_mark_last_busy(rsb->dev);
363 pm_runtime_put_autosuspend(rsb->dev);
368 static int sunxi_rsb_write(struct sunxi_rsb *rsb, u8 rtaddr, u8 addr,
369 const u32 *buf, size_t len)
388 dev_err(rsb->dev, "Invalid access width: %zd\n", len);
392 ret = pm_runtime_resume_and_get(rsb->dev);
396 mutex_lock(&rsb->lock);
398 writel(addr, rsb->regs + RSB_ADDR);
399 writel(RSB_DAR_RTA(rtaddr), rsb->regs + RSB_DAR);
400 writel(*buf, rsb->regs + RSB_DATA);
401 writel(cmd, rsb->regs + RSB_CMD);
402 ret = _sunxi_rsb_run_xfer(rsb);
404 mutex_unlock(&rsb->lock);
406 pm_runtime_mark_last_busy(rsb->dev);
407 pm_runtime_put_autosuspend(rsb->dev);
412 /* RSB regmap functions */
413 struct sunxi_rsb_ctx {
414 struct sunxi_rsb_device *rdev;
418 static int regmap_sunxi_rsb_reg_read(void *context, unsigned int reg,
421 struct sunxi_rsb_ctx *ctx = context;
422 struct sunxi_rsb_device *rdev = ctx->rdev;
427 return sunxi_rsb_read(rdev->rsb, rdev->rtaddr, reg, val, ctx->size);
430 static int regmap_sunxi_rsb_reg_write(void *context, unsigned int reg,
433 struct sunxi_rsb_ctx *ctx = context;
434 struct sunxi_rsb_device *rdev = ctx->rdev;
436 return sunxi_rsb_write(rdev->rsb, rdev->rtaddr, reg, &val, ctx->size);
439 static void regmap_sunxi_rsb_free_ctx(void *context)
441 struct sunxi_rsb_ctx *ctx = context;
446 static struct regmap_bus regmap_sunxi_rsb = {
447 .reg_write = regmap_sunxi_rsb_reg_write,
448 .reg_read = regmap_sunxi_rsb_reg_read,
449 .free_context = regmap_sunxi_rsb_free_ctx,
450 .reg_format_endian_default = REGMAP_ENDIAN_NATIVE,
451 .val_format_endian_default = REGMAP_ENDIAN_NATIVE,
454 static struct sunxi_rsb_ctx *regmap_sunxi_rsb_init_ctx(struct sunxi_rsb_device *rdev,
455 const struct regmap_config *config)
457 struct sunxi_rsb_ctx *ctx;
459 switch (config->val_bits) {
465 return ERR_PTR(-EINVAL);
468 ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
470 return ERR_PTR(-ENOMEM);
473 ctx->size = config->val_bits / 8;
478 struct regmap *__devm_regmap_init_sunxi_rsb(struct sunxi_rsb_device *rdev,
479 const struct regmap_config *config,
480 struct lock_class_key *lock_key,
481 const char *lock_name)
483 struct sunxi_rsb_ctx *ctx = regmap_sunxi_rsb_init_ctx(rdev, config);
486 return ERR_CAST(ctx);
488 return __devm_regmap_init(&rdev->dev, ®map_sunxi_rsb, ctx, config,
489 lock_key, lock_name);
491 EXPORT_SYMBOL_GPL(__devm_regmap_init_sunxi_rsb);
493 /* RSB controller driver functions */
494 static irqreturn_t sunxi_rsb_irq(int irq, void *dev_id)
496 struct sunxi_rsb *rsb = dev_id;
499 status = readl(rsb->regs + RSB_INTS);
500 rsb->status = status;
502 /* Clear interrupts */
503 status &= (RSB_INTS_LOAD_BSY | RSB_INTS_TRANS_ERR |
504 RSB_INTS_TRANS_OVER);
505 writel(status, rsb->regs + RSB_INTS);
507 complete(&rsb->complete);
512 static int sunxi_rsb_init_device_mode(struct sunxi_rsb *rsb)
517 /* send init sequence */
518 writel(RSB_DMCR_DEVICE_START | RSB_DMCR_MODE_DATA |
519 RSB_DMCR_MODE_REG | RSB_DMCR_DEV_ADDR, rsb->regs + RSB_DMCR);
521 readl_poll_timeout(rsb->regs + RSB_DMCR, reg,
522 !(reg & RSB_DMCR_DEVICE_START), 100, 250000);
523 if (reg & RSB_DMCR_DEVICE_START)
526 /* clear interrupt status bits */
527 writel(readl(rsb->regs + RSB_INTS), rsb->regs + RSB_INTS);
533 * There are 15 valid runtime addresses, though Allwinner typically
534 * skips the first, for unknown reasons, and uses the following three.
536 * 0x17, 0x2d, 0x3a, 0x4e, 0x59, 0x63, 0x74, 0x8b,
537 * 0x9c, 0xa6, 0xb1, 0xc5, 0xd2, 0xe8, 0xff
539 * No designs with 2 RSB slave devices sharing identical hardware
540 * addresses on the same bus have been seen in the wild. All designs
541 * use 0x2d for the primary PMIC, 0x3a for the secondary PMIC if
542 * there is one, and 0x45 for peripheral ICs.
544 * The hardware does not seem to support re-setting runtime addresses.
545 * Attempts to do so result in the slave devices returning a NACK.
546 * Hence we just hardcode the mapping here, like Allwinner does.
549 static const struct sunxi_rsb_addr_map sunxi_rsb_addr_maps[] = {
550 { 0x3a3, 0x2d }, /* Primary PMIC: AXP223, AXP809, AXP81X, ... */
551 { 0x745, 0x3a }, /* Secondary PMIC: AXP806, ... */
552 { 0xe89, 0x4e }, /* Peripheral IC: AC100, ... */
555 static u8 sunxi_rsb_get_rtaddr(u16 hwaddr)
559 for (i = 0; i < ARRAY_SIZE(sunxi_rsb_addr_maps); i++)
560 if (hwaddr == sunxi_rsb_addr_maps[i].hwaddr)
561 return sunxi_rsb_addr_maps[i].rtaddr;
563 return 0; /* 0 is an invalid runtime address */
566 static int of_rsb_register_devices(struct sunxi_rsb *rsb)
568 struct device *dev = rsb->dev;
569 struct device_node *child, *np = dev->of_node;
577 /* Runtime addresses for all slaves should be set first */
578 for_each_available_child_of_node(np, child) {
579 dev_dbg(dev, "setting child %pOF runtime address\n",
582 ret = of_property_read_u32(child, "reg", &hwaddr);
584 dev_err(dev, "%pOF: invalid 'reg' property: %d\n",
589 rtaddr = sunxi_rsb_get_rtaddr(hwaddr);
591 dev_err(dev, "%pOF: unknown hardware device address\n",
597 * Since no devices have been registered yet, we are the
598 * only ones using the bus, we can skip locking the bus.
601 /* setup command parameters */
602 writel(RSB_CMD_STRA, rsb->regs + RSB_CMD);
603 writel(RSB_DAR_RTA(rtaddr) | RSB_DAR_DA(hwaddr),
604 rsb->regs + RSB_DAR);
607 ret = _sunxi_rsb_run_xfer(rsb);
609 dev_warn(dev, "%pOF: set runtime address failed: %d\n",
613 /* Then we start adding devices and probing them */
614 for_each_available_child_of_node(np, child) {
615 struct sunxi_rsb_device *rdev;
617 dev_dbg(dev, "adding child %pOF\n", child);
619 ret = of_property_read_u32(child, "reg", &hwaddr);
623 rtaddr = sunxi_rsb_get_rtaddr(hwaddr);
627 rdev = sunxi_rsb_device_create(rsb, child, hwaddr, rtaddr);
629 dev_err(dev, "failed to add child device %pOF: %ld\n",
630 child, PTR_ERR(rdev));
636 static int sunxi_rsb_hw_init(struct sunxi_rsb *rsb)
638 struct device *dev = rsb->dev;
639 unsigned long p_clk_freq;
643 ret = clk_prepare_enable(rsb->clk);
645 dev_err(dev, "failed to enable clk: %d\n", ret);
649 ret = reset_control_deassert(rsb->rstc);
651 dev_err(dev, "failed to deassert reset line: %d\n", ret);
652 goto err_clk_disable;
655 /* reset the controller */
656 writel(RSB_CTRL_SOFT_RST, rsb->regs + RSB_CTRL);
657 readl_poll_timeout(rsb->regs + RSB_CTRL, reg,
658 !(reg & RSB_CTRL_SOFT_RST), 1000, 100000);
661 * Clock frequency and delay calculation code is from
662 * Allwinner U-boot sources.
664 * From A83 user manual:
665 * bus clock frequency = parent clock frequency / (2 * (divider + 1))
667 p_clk_freq = clk_get_rate(rsb->clk);
668 clk_div = p_clk_freq / rsb->clk_freq / 2;
671 else if (clk_div > RSB_CCR_MAX_CLK_DIV + 1)
672 clk_div = RSB_CCR_MAX_CLK_DIV + 1;
674 clk_delay = clk_div >> 1;
678 dev_info(dev, "RSB running at %lu Hz\n", p_clk_freq / clk_div / 2);
679 writel(RSB_CCR_SDA_OUT_DELAY(clk_delay) | RSB_CCR_CLK_DIV(clk_div - 1),
680 rsb->regs + RSB_CCR);
685 clk_disable_unprepare(rsb->clk);
690 static void sunxi_rsb_hw_exit(struct sunxi_rsb *rsb)
692 /* Keep the clock and PM reference counts consistent. */
693 if (pm_runtime_status_suspended(rsb->dev))
694 pm_runtime_resume(rsb->dev);
695 reset_control_assert(rsb->rstc);
696 clk_disable_unprepare(rsb->clk);
699 static int __maybe_unused sunxi_rsb_runtime_suspend(struct device *dev)
701 struct sunxi_rsb *rsb = dev_get_drvdata(dev);
703 clk_disable_unprepare(rsb->clk);
708 static int __maybe_unused sunxi_rsb_runtime_resume(struct device *dev)
710 struct sunxi_rsb *rsb = dev_get_drvdata(dev);
712 return clk_prepare_enable(rsb->clk);
715 static int __maybe_unused sunxi_rsb_suspend(struct device *dev)
717 struct sunxi_rsb *rsb = dev_get_drvdata(dev);
719 sunxi_rsb_hw_exit(rsb);
724 static int __maybe_unused sunxi_rsb_resume(struct device *dev)
726 struct sunxi_rsb *rsb = dev_get_drvdata(dev);
728 return sunxi_rsb_hw_init(rsb);
731 static int sunxi_rsb_probe(struct platform_device *pdev)
733 struct device *dev = &pdev->dev;
734 struct device_node *np = dev->of_node;
736 struct sunxi_rsb *rsb;
737 u32 clk_freq = 3000000;
740 of_property_read_u32(np, "clock-frequency", &clk_freq);
741 if (clk_freq > RSB_MAX_FREQ) {
743 "clock-frequency (%u Hz) is too high (max = 20MHz)\n",
748 rsb = devm_kzalloc(dev, sizeof(*rsb), GFP_KERNEL);
753 rsb->clk_freq = clk_freq;
754 platform_set_drvdata(pdev, rsb);
755 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
756 rsb->regs = devm_ioremap_resource(dev, r);
757 if (IS_ERR(rsb->regs))
758 return PTR_ERR(rsb->regs);
760 irq = platform_get_irq(pdev, 0);
764 rsb->clk = devm_clk_get(dev, NULL);
765 if (IS_ERR(rsb->clk)) {
766 ret = PTR_ERR(rsb->clk);
767 dev_err(dev, "failed to retrieve clk: %d\n", ret);
771 rsb->rstc = devm_reset_control_get(dev, NULL);
772 if (IS_ERR(rsb->rstc)) {
773 ret = PTR_ERR(rsb->rstc);
774 dev_err(dev, "failed to retrieve reset controller: %d\n", ret);
778 init_completion(&rsb->complete);
779 mutex_init(&rsb->lock);
781 ret = devm_request_irq(dev, irq, sunxi_rsb_irq, 0, RSB_CTRL_NAME, rsb);
783 dev_err(dev, "can't register interrupt handler irq %d: %d\n",
788 ret = sunxi_rsb_hw_init(rsb);
792 /* initialize all devices on the bus into RSB mode */
793 ret = sunxi_rsb_init_device_mode(rsb);
795 dev_warn(dev, "Initialize device mode failed: %d\n", ret);
797 pm_suspend_ignore_children(dev, true);
798 pm_runtime_set_active(dev);
799 pm_runtime_set_autosuspend_delay(dev, MSEC_PER_SEC);
800 pm_runtime_use_autosuspend(dev);
801 pm_runtime_enable(dev);
803 of_rsb_register_devices(rsb);
808 static int sunxi_rsb_remove(struct platform_device *pdev)
810 struct sunxi_rsb *rsb = platform_get_drvdata(pdev);
812 device_for_each_child(rsb->dev, NULL, sunxi_rsb_remove_devices);
813 pm_runtime_disable(&pdev->dev);
814 sunxi_rsb_hw_exit(rsb);
819 static void sunxi_rsb_shutdown(struct platform_device *pdev)
821 struct sunxi_rsb *rsb = platform_get_drvdata(pdev);
823 pm_runtime_disable(&pdev->dev);
824 sunxi_rsb_hw_exit(rsb);
827 static const struct dev_pm_ops sunxi_rsb_dev_pm_ops = {
828 SET_RUNTIME_PM_OPS(sunxi_rsb_runtime_suspend,
829 sunxi_rsb_runtime_resume, NULL)
830 SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(sunxi_rsb_suspend, sunxi_rsb_resume)
833 static const struct of_device_id sunxi_rsb_of_match_table[] = {
834 { .compatible = "allwinner,sun8i-a23-rsb" },
837 MODULE_DEVICE_TABLE(of, sunxi_rsb_of_match_table);
839 static struct platform_driver sunxi_rsb_driver = {
840 .probe = sunxi_rsb_probe,
841 .remove = sunxi_rsb_remove,
842 .shutdown = sunxi_rsb_shutdown,
844 .name = RSB_CTRL_NAME,
845 .of_match_table = sunxi_rsb_of_match_table,
846 .pm = &sunxi_rsb_dev_pm_ops,
850 static int __init sunxi_rsb_init(void)
854 ret = bus_register(&sunxi_rsb_bus);
856 pr_err("failed to register sunxi sunxi_rsb bus: %d\n", ret);
860 return platform_driver_register(&sunxi_rsb_driver);
862 module_init(sunxi_rsb_init);
864 static void __exit sunxi_rsb_exit(void)
866 platform_driver_unregister(&sunxi_rsb_driver);
867 bus_unregister(&sunxi_rsb_bus);
869 module_exit(sunxi_rsb_exit);
871 MODULE_AUTHOR("Chen-Yu Tsai <wens@csie.org>");
872 MODULE_DESCRIPTION("Allwinner sunXi Reduced Serial Bus controller driver");
873 MODULE_LICENSE("GPL v2");